Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fvm user interface improvements #3683

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use crate::common::version_directory::VersionDirectory;
use crate::common::workdir::fvm_versions_path;

#[derive(Debug, Parser)]
pub struct ShowOpt;
pub struct ListOpt;

impl ShowOpt {
impl ListOpt {
pub async fn process(&self, notify: Notify) -> Result<()> {
let versions_path = fvm_versions_path()?;

Expand Down
2 changes: 1 addition & 1 deletion crates/fluvio-version-manager/src/command/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod current;
pub mod install;
pub mod itself;
pub mod show;
pub mod list;
pub mod switch;
pub mod update;
pub mod version;
18 changes: 13 additions & 5 deletions crates/fluvio-version-manager/src/command/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl SwitchOpt {
let Some(version) = &self.version else {
notify.help(format!(
"You can use {} to see installed versions",
"fvm show".bold()
"fvm list".bold()
));

return Err(anyhow::anyhow!("No version provided"));
Expand Down Expand Up @@ -69,10 +69,18 @@ impl SwitchOpt {

version_dir.set_active()?;

notify.done(format!(
"Now using Fluvio version {}",
version.to_string().bold(),
));
if version.is_version_tag() {
notify.done(format!(
"Now using Fluvio version {}",
version.to_string().bold(),
));
} else {
notify.done(format!(
"Now using Fluvio {} ({})",
version.to_string().bold(),
version_dir.manifest.version.to_string().bold(),
));
}
Comment on lines +72 to +83
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For version tags, say fvm switch 0.10.11, rendering the tag between parenthesis is redundant so its discriminated by the nature of the Channel instance provided.

We just want to render the specific tag for Channels.

fvm switch 0.10.15
...
done: Now using Fluvio version 0.10.15

And with Channels

fvm switch stable
...
done: Now using Fluvio stable (0.10.17)


Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions crates/fluvio-version-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use clap::Parser;
use self::command::current::CurrentOpt;
use self::command::install::InstallOpt;
use self::command::itself::SelfOpt;
use self::command::show::ShowOpt;
use self::command::list::ListOpt;
use self::command::switch::SwitchOpt;
use self::command::update::UpdateOpt;
use self::command::version::VersionOpt;
Expand Down Expand Up @@ -55,8 +55,8 @@ pub enum Command {
#[command(name = "install")]
Install(InstallOpt),
/// List installed Fluvio Versions
#[command(name = "show")]
Show(ShowOpt),
#[command(name = "list")]
List(ListOpt),
/// Set a installed Fluvio Version as active
#[command(name = "switch")]
Switch(SwitchOpt),
Expand All @@ -77,7 +77,7 @@ impl Cli {
Command::Current(cmd) => cmd.process(notify).await,
Command::Itself(cmd) => cmd.process(notify).await,
Command::Install(cmd) => cmd.process(notify).await,
Command::Show(cmd) => cmd.process(notify).await,
Command::List(cmd) => cmd.process(notify).await,
Command::Switch(cmd) => cmd.process(notify).await,
Command::Update(cmd) => cmd.process(notify).await,
Command::Version(cmd) => cmd.process(),
Expand Down
16 changes: 8 additions & 8 deletions tests/cli/fvm_smoke_tests/fvm_basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ setup_file() {
# Sets `fvm` in the PATH using the "env" file included in the installation
source ~/.fvm/env

# Renders warn if attempts to use `fvm show` and no versions are installed
run bash -c 'fvm show'
# Renders warn if attempts to use `fvm list` and no versions are installed
run bash -c 'fvm list'
assert_line --index 0 "warn: No installed versions found"
assert_line --index 1 "help: You can install a Fluvio version using the command fvm install"
assert_success
Expand Down Expand Up @@ -422,8 +422,8 @@ setup_file() {
assert_output --partial "channel = \"stable\""
assert_success

# Checks the version is set as active in show list
run bash -c 'fvm show'
# Checks the version is set as active in list list
run bash -c 'fvm list'
assert_line --index 0 --partial " CHANNEL VERSION"
assert_line --index 1 --partial " ✓ stable $STABLE_VERSION"
assert_line --index 2 --partial " 0.10.14 0.10.14"
Expand Down Expand Up @@ -453,8 +453,8 @@ setup_file() {
assert_output --partial "tag = \"0.10.14\""
assert_success

# Checks the version is set as active in show list
run bash -c 'fvm show'
# Checks the version is set as active in list
run bash -c 'fvm list'
assert_line --index 0 --partial " CHANNEL VERSION"
assert_line --index 1 --partial " ✓ 0.10.14 0.10.14"
assert_line --index 2 --partial " stable $STABLE_VERSION"
Expand All @@ -474,15 +474,15 @@ setup_file() {
assert_success
}

@test "Recommends using fvm show to list available versions" {
@test "Recommends using fvm list to list available versions" {
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 switch'
assert_line --index 0 "help: You can use fvm show to see installed versions"
assert_line --index 0 "help: You can use fvm list to see installed versions"
assert_line --index 1 "Error: No version provided"
assert_failure

Expand Down
Loading