diff --git a/src/cli_util.rs b/src/cli_util.rs index f06adb92c..01d68f806 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -2294,6 +2294,12 @@ impl CliRunner { } } + /// Set the version to be displayed by `jj version`. + pub fn version(mut self, version: &'static str) -> Self { + self.app = self.app.version(version); + self + } + /// Replaces `StoreFactories` to be used. pub fn set_store_factories(mut self, store_factories: StoreFactories) -> Self { self.store_factories = Some(store_factories); diff --git a/src/commands/mod.rs b/src/commands/mod.rs index aaee12f69..a2d7d0b8d 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -3473,8 +3473,7 @@ fn cmd_sparse(ui: &mut Ui, command: &CommandHelper, args: &SparseArgs) -> Result } pub fn default_app() -> Command { - let app: Command = Commands::augment_subcommands(Args::command()); - app.version(env!("JJ_VERSION")) + Commands::augment_subcommands(Args::command()) } pub fn run_command( diff --git a/src/main.rs b/src/main.rs index b070d557e..21d1d75a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,5 +15,5 @@ use jujutsu::cli_util::CliRunner; fn main() -> std::process::ExitCode { - CliRunner::init().run() + CliRunner::init().version(env!("JJ_VERSION")).run() }