Skip to content

Commit

Permalink
refactor: Version string may be on app.rs better than managed on main.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei committed Mar 10, 2024
1 parent fe0412e commit 4071bc2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .age.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ search = "version = \"{{current_version}}\""
replace = "version = \"{{new_version}}\""

[[files]]
path = "src/main.rs"
search = "const VERSION: &'static str = \"{{current_version}}\";"
replace = "const VERSION: &'static str = \"{{new_version}}\";"
path = "src/app.rs"
search = "pub const VERSION: &'static str = \"{{current_version}}\";"
replace = "pub const VERSION: &'static str = \"{{new_version}}\";"
2 changes: 2 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use toml::to_string;

use crate::config::{find_config_path, Config};

pub const VERSION: &'static str = "0.2.0";

pub fn update(base_config: &Config, new_version: &Version) -> Result<()> {
let mut new_config = base_config.clone();
new_config.current_version = new_version.clone();
Expand Down
3 changes: 2 additions & 1 deletion src/commands/version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::app::VERSION;
use anyhow::Result;

pub fn execute() -> Result<()> {
let version = super::super::VERSION;
let version = VERSION;
println!("Running age v{version}");
Ok(())
}
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ mod versioning;
use clap::{Parser, Subcommand};
use semver::Version;

const VERSION: &'static str = "0.2.0";

#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Cli {
Expand Down

0 comments on commit 4071bc2

Please sign in to comment.