diff options
author | Cyborus <cyborus@noreply.codeberg.org> | 2024-12-12 20:36:07 +0100 |
---|---|---|
committer | Cyborus <cyborus@noreply.codeberg.org> | 2024-12-12 20:36:07 +0100 |
commit | 9db33e37e4c709a345a0b3154879f5ba1f790d4b (patch) | |
tree | 05dd371182d1fc65210d2f6ae9c25ddfb5b2c1bc | |
parent | Merge pull request 'bump version in `flake.nix` to 0.2.0' (#148) from bump-fl... (diff) | |
parent | feat: add --verbose flag to version command (diff) | |
download | forgejo-cli-9db33e37e4c709a345a0b3154879f5ba1f790d4b.tar.xz forgejo-cli-9db33e37e4c709a345a0b3154879f5ba1f790d4b.zip |
Merge pull request 'add `version --verbose`' (#149) from verbose-version into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/149
-rw-r--r-- | .woodpecker/deploy.yml | 4 | ||||
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | build.rs | 6 | ||||
-rw-r--r-- | flake.nix | 4 | ||||
-rw-r--r-- | src/version.rs | 14 |
6 files changed, 32 insertions, 1 deletions
diff --git a/.woodpecker/deploy.yml b/.woodpecker/deploy.yml index 18f88e4..8db6d24 100644 --- a/.woodpecker/deploy.yml +++ b/.woodpecker/deploy.yml @@ -3,6 +3,8 @@ when: steps: compile-linux: image: rust:latest + environment: + BUILD_TYPE: "release ci" commands: - rustup target add x86_64-unknown-linux-gnu - cargo build --target=x86_64-unknown-linux-gnu --release --features update-check @@ -10,6 +12,8 @@ steps: secrets: [ client_info_codeberg ] compile-windows: image: rust:latest + environment: + BUILD_TYPE: "release ci" commands: - rustup target add x86_64-pc-windows-gnu - apt update @@ -603,6 +603,7 @@ version = "0.2.0" dependencies = [ "auth-git2", "base64ct", + "cfg-if", "clap", "comrak", "crossterm", @@ -20,6 +20,7 @@ update-check = ["dep:semver"] [dependencies] auth-git2 = "0.5.4" base64ct = { version = "1.6.0", features = ["std"] } +cfg-if = "1.0.0" clap = { version = "4.5.11", features = ["derive"] } comrak = "0.26.0" crossterm = "0.27.0" @@ -42,3 +43,6 @@ tokio = { version = "1.39.1", features = ["full"] } url = "2.5.2" uuid = { version = "1.10.0", features = ["v4"] } +[build-dependencies] +git2 = "0.19.0" + diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..e0ebd1c --- /dev/null +++ b/build.rs @@ -0,0 +1,6 @@ +fn main() { + println!( + "cargo:rustc-env=BUILD_TARGET={}", + std::env::var("TARGET").unwrap() + ); +} @@ -24,6 +24,10 @@ homepage = "https://codeberg.org/Cyborus/forgejo-cli/"; license = with licenses; [ asl20 /* or */ mit ]; }; + + env = { + BUILD_TYPE = "flake"; + }; }; packages.default = packages.forgejo-cli; diff --git a/src/version.rs b/src/version.rs index 70cae8d..f3ab776 100644 --- a/src/version.rs +++ b/src/version.rs @@ -8,11 +8,23 @@ pub struct VersionCommand { #[clap(long)] #[cfg(feature = "update-check")] check: bool, + #[clap(short, long)] + verbose: bool, } +const BUILD_TYPE: &str = match option_env!("BUILD_TYPE") { + Some(s) => s, + None => "from source", +}; + impl VersionCommand { pub async fn run(self) -> eyre::Result<()> { - println!("{}", env!("CARGO_PKG_VERSION")); + println!("{} v{}", env!("CARGO_BIN_NAME"), env!("CARGO_PKG_VERSION")); + if self.verbose { + println!("user agent: {}", crate::keys::USER_AGENT); + println!("build type: {BUILD_TYPE}"); + println!(" target: {}", env!("BUILD_TARGET")); + } #[cfg(feature = "update-check")] self.update_msg().await?; Ok(()) |