diff --git a/crates/ty/Cargo.toml b/crates/ty/Cargo.toml index 9ce23eb648..813cbdb30d 100644 --- a/crates/ty/Cargo.toml +++ b/crates/ty/Cargo.toml @@ -20,7 +20,7 @@ ty_server = { workspace = true } anyhow = { workspace = true } argfile = { workspace = true } -clap = { workspace = true, features = ["wrap_help"] } +clap = { workspace = true, features = ["wrap_help", "string"] } colored = { workspace = true } countme = { workspace = true, features = ["enable"] } crossbeam = { workspace = true } diff --git a/crates/ty/src/args.rs b/crates/ty/src/args.rs index 5049bd1551..c9969d0f9c 100644 --- a/crates/ty/src/args.rs +++ b/crates/ty/src/args.rs @@ -8,7 +8,7 @@ use ty_python_semantic::lint; #[derive(Debug, Parser)] #[command(author, name = "ty", about = "An extremely fast Python type checker.")] -#[command(version)] +#[command(long_version = crate::version::version())] pub(crate) struct Args { #[command(subcommand)] pub(crate) command: Command, diff --git a/crates/ty/src/version.rs b/crates/ty/src/version.rs index a851afc8c7..d063de5277 100644 --- a/crates/ty/src/version.rs +++ b/crates/ty/src/version.rs @@ -35,6 +35,12 @@ impl fmt::Display for VersionInfo { } } +impl From for clap::builder::Str { + fn from(val: VersionInfo) -> Self { + val.to_string().into() + } +} + /// Returns information about ty's version. pub(crate) fn version() -> VersionInfo { // Environment variables are only read at compile-time