summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.woodpecker/deploy.yml4
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml4
-rw-r--r--build.rs6
-rw-r--r--flake.nix4
-rw-r--r--src/version.rs14
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
diff --git a/Cargo.lock b/Cargo.lock
index 08759eb..51cffcf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -603,6 +603,7 @@ version = "0.1.1"
dependencies = [
"auth-git2",
"base64ct",
+ "cfg-if",
"clap",
"comrak",
"crossterm",
diff --git a/Cargo.toml b/Cargo.toml
index c0815e5..aba4c63 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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()
+ );
+}
diff --git a/flake.nix b/flake.nix
index 885922e..bd2bef1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -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(())