Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

feat: orb version command #741

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 85 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ base64 = { version = "^0.21" }
byteorder = { version = "~1.4" } # keep in sync with pinned libipld-* crates
bytes = { version = "^1" }
cid = { version = "0.10" }
clap-vergen = { version = "0.2.0" }
deterministic-bloom = { version = "0.1.0" }
directories = { version = "5" }
fastcdc = { version = "3.1" }
Expand Down Expand Up @@ -65,6 +66,8 @@ tracing-subscriber = { version = "~0.3.18", features = ["env-filter", "tracing-l
ucan = { version = "0.4.0" }
ucan-key-support = { version = "0.1.7" }
url = { version = "^2" }
vergen = { version = "8.2.6", features = ["build", "cargo", "git", "gitcl"] }
vergen-pretty = { version = "0.3.0" }
void = { version = "1" }
wasm-bindgen = { version = "^0.2" }
wasm-bindgen-test = { version = "^0.3" }
Expand Down
6 changes: 6 additions & 0 deletions rust/noosphere-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ rocksdb = ["noosphere/rocksdb"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
vergen = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
reqwest = { version = "~0.11", default-features = false, features = ["json", "rustls-tls", "stream"] }

Expand Down Expand Up @@ -54,6 +57,9 @@ noosphere-ns = { version = "0.11.5", path = "../noosphere-ns", optional = true }
noosphere = { version = "0.16.0", path = "../noosphere" }
ucan = { workspace = true }
ucan-key-support = { workspace = true }

vergen-pretty = { workspace = true }

cid = { workspace = true }
symlink = { workspace = true }
pathdiff = { workspace = true }
Expand Down
10 changes: 10 additions & 0 deletions rust/noosphere-cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use vergen::EmitBuilder;

fn main() {
EmitBuilder::builder()
.all_git()
.all_build()
.all_cargo()
.emit()
.unwrap();
}
7 changes: 7 additions & 0 deletions rust/noosphere-cli/src/native/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ pub enum OrbCommand {
command: SphereCommand,
},

/// Display version information for this build of the CLI
Version {
/// Display extra build and git metadata
#[clap(short, long)]
verbose: bool,
},

/// Summon a gateway geist to manage the local sphere; it will accept
/// push, fetch and other REST actions from any clients that are authorized
/// to operate on its counterpart sphere. When it receives changes to its
Expand Down
Empty file.
17 changes: 17 additions & 0 deletions rust/noosphere-cli/src/native/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use anyhow::Result;
use clap::Parser;
use noosphere_core::tracing::initialize_tracing;
use noosphere_storage::StorageConfig;
use vergen_pretty::{vergen_pretty_env, PrettyBuilder};

/// Additional context used to invoke a [Cli] command.
pub struct CliContext<'a> {
Expand Down Expand Up @@ -85,6 +86,22 @@ pub async fn invoke_cli_with_workspace(cli: Cli, mut workspace: Workspace) -> Re
KeyCommand::Create { name } => key_create(&name, &workspace).await?,
KeyCommand::List { as_json } => key_list(as_json, &workspace).await?,
},
OrbCommand::Version { verbose } => {
let version = env!("CARGO_PKG_VERSION");

if verbose {
let mut out = Vec::new();
PrettyBuilder::default()
.env(vergen_pretty_env!())
.build()?
.display(&mut out)?;

info!("{:>28}: {}", "Version ( orb)", version);
info!("{}", std::str::from_utf8(&out)?);
} else {
info!("{}", version);
}
}
OrbCommand::Sphere { command } => match command {
SphereCommand::Create { owner_key } => {
sphere_create(&owner_key, &mut workspace).await?;
Expand Down
Loading