Skip to content

Commit

Permalink
cli: allow non-static version strings from custom binaries
Browse files Browse the repository at this point in the history
We would like to use a non-static version string at Google. We have a
workaround using Lazy, but it seems unfortunate to have to do
that. Using dynamic strings requires Clap's `string` feature, which
increases the binary size by 140 kiB (0.6%).
  • Loading branch information
martinvonz committed Jan 6, 2024
1 parent 546fe73 commit 9bee1c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ backoff = "0.4.0"
blake2 = "0.10.6"
bytes = "1.5.0"
cargo_metadata = "0.17.0"
clap = { version = "4.4.13", features = ["derive", "deprecated", "wrap_help"] }
clap = { version = "4.4.13", features = [
"derive",
"deprecated",
"wrap_help",
"string",
] }
clap_complete = "4.4.6"
clap_mangen = "0.2.10"
chrono = { version = "0.4.31", default-features = false, features = [
Expand Down
4 changes: 2 additions & 2 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2783,8 +2783,8 @@ 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);
pub fn version(mut self, version: &str) -> Self {
self.app = self.app.version(version.to_string());
self
}

Expand Down

0 comments on commit 9bee1c3

Please sign in to comment.