cli: allow non-static version strings from custom binaries

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%).
This commit is contained in:
Martin von Zweigbergk 2024-01-06 07:09:00 -08:00 committed by Martin von Zweigbergk
parent e354816236
commit 0046af8d4c
2 changed files with 8 additions and 3 deletions

View file

@ -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 = [

View file

@ -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
}