Skip to content

Commit

Permalink
feat: fvm version command
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanBorai committed Oct 25, 2023
1 parent 4c0f1e8 commit 4c57839
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion crates/fluvio-version-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 7 additions & 3 deletions crates/fluvio-version-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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")]
Expand All @@ -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 {
Expand All @@ -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")),
}
}
}
26 changes: 26 additions & 0 deletions tests/cli/fvm_smoke_tests/fvm_basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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
}

0 comments on commit 4c57839

Please sign in to comment.