From 4c57839f64aaaad6e62927055be8a2ffa8ca7365 Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 25 Oct 2023 14:30:46 -0300 Subject: [PATCH] feat: fvm version command --- Cargo.lock | 3 ++- crates/fluvio-version-manager/Cargo.toml | 3 ++- crates/fluvio-version-manager/src/main.rs | 10 ++++++--- tests/cli/fvm_smoke_tests/fvm_basic.bats | 26 +++++++++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b566097b597..8675ff6acf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2697,7 +2697,7 @@ dependencies = [ [[package]] name = "fluvio-compression" -version = "0.3.1" +version = "0.3.2" dependencies = [ "bytes 1.5.0", "flate2", @@ -3415,6 +3415,7 @@ dependencies = [ "comfy-table", "dialoguer 0.11.0", "dirs 5.0.1", + "fluvio-cli-common", "fluvio-future", "fluvio-hub-util", "fs_extra", diff --git a/crates/fluvio-version-manager/Cargo.toml b/crates/fluvio-version-manager/Cargo.toml index 2e09f3658a3..9996084cd6d 100644 --- a/crates/fluvio-version-manager/Cargo.toml +++ b/crates/fluvio-version-manager/Cargo.toml @@ -33,8 +33,9 @@ toml = { workspace = true } url = { workspace = true } # Workspace Crates -fluvio-hub-util = { workspace = true } +fluvio-cli-common = { workspace = true, default-features = false, features = ["version-cmd"] } fluvio-future = { workspace = true, features = ["subscriber"] } +fluvio-hub-util = { workspace = true } [dev-dependencies] fs_extra = "1.3.0" diff --git a/crates/fluvio-version-manager/src/main.rs b/crates/fluvio-version-manager/src/main.rs index 274ced6df1d..0430f3b818a 100644 --- a/crates/fluvio-version-manager/src/main.rs +++ b/crates/fluvio-version-manager/src/main.rs @@ -3,11 +3,13 @@ mod common; use anyhow::Result; use clap::Parser; -use command::current::CurrentOpt; -use command::show::ShowOpt; +use fluvio_cli_common::version_cmd::BasicVersionCmd; + +use self::command::current::CurrentOpt; use self::command::install::InstallOpt; use self::command::itself::SelfOpt; +use self::command::show::ShowOpt; use self::command::switch::SwitchOpt; use self::common::notify::Notify; @@ -26,7 +28,6 @@ async fn main() -> Result<()> { about = "Fluvio Version Manager (FVM)", name = "fvm", max_term_width = 100, - version = env!("CARGO_PKG_VERSION") )] pub struct Cli { #[clap(long, short = 'q', help = "Suppress all output")] @@ -52,6 +53,8 @@ pub enum Command { /// Set a installed Fluvio Version as active #[command(name = "switch")] Switch(SwitchOpt), + /// Prints version information + Version(BasicVersionCmd), } impl Cli { @@ -66,6 +69,7 @@ impl Cli { Command::Install(cmd) => cmd.process(notify).await, Command::Show(cmd) => cmd.process(notify).await, Command::Switch(cmd) => cmd.process(notify).await, + Command::Version(cmd) => cmd.process(env!("CARGO_BIN_NAME")), } } } diff --git a/tests/cli/fvm_smoke_tests/fvm_basic.bats b/tests/cli/fvm_smoke_tests/fvm_basic.bats index e193d267d1b..bcad2232f88 100644 --- a/tests/cli/fvm_smoke_tests/fvm_basic.bats +++ b/tests/cli/fvm_smoke_tests/fvm_basic.bats @@ -47,6 +47,10 @@ setup_file() { FLUVIO_BINARIES_DIR="$FLUVIO_HOME_DIR/bin" export FLUVIO_BINARIES_DIR debug_msg "Fluvio Binaries Directory: $FLUVIO_BINARIES_DIR" + + VERSION_FILE_VALUE="$(cat ../../../VERSION)" + export VERSION_FILE_VALUE + debug_msg "Version File Value: $VERSION_FILE_VALUE" } @test "Install fvm and setup a settings.toml file" { @@ -643,3 +647,25 @@ setup_file() { rm -rf $FLUVIO_HOME_DIR assert_success } + +@test "Prints version with details on fvm version" { + run bash -c '$FVM_BIN self install' + assert_success + + # Sets `fvm` in the PATH using the "env" file included in the installation + source ~/.fvm/env + + run bash -c 'fvm version' + assert_line --index 0 "fvm CLI: $VERSION_FILE_VALUE" + assert_line --index 1 --partial "fvm CLI Arch" + assert_line --index 2 --partial "fvm CLI SHA256" + assert_success + + # Removes FVM + run bash -c 'fvm self uninstall --yes' + assert_success + + # Removes Fluvio + rm -rf $FLUVIO_HOME_DIR + assert_success +}