From 39e83b9f4a75bf9a7fd76b59933aa9ccd475f15b Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 20 Apr 2023 15:17:08 -0700 Subject: [PATCH] cli: move `$JJ_VERSION` out of CLI library It should be up to the binary to decide which version it is. One should be able to build the library without specifying a version. --- src/cli_util.rs | 6 ++++++ src/commands/mod.rs | 3 +-- src/main.rs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) 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() }