-
Notifications
You must be signed in to change notification settings - Fork 497
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
[Merged by Bors] - feat: fvm show
and fvm current
command
#3601
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f9c9216
feat: `fvm show` command for listing versions
EstebanBorai 4f16924
feat: `fvm current` command for active version
EstebanBorai 8f4554f
feat: message for empty version list on `fvm show`
EstebanBorai 8c1db1c
chore: move `scan_versions_manifests` into `VersionManifest` `impl`
EstebanBorai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
crates/fluvio-version-manager/fixtures/version/0.10.15/fluvio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
echo "Fluvio Test Executable 0.10.15" |
6 changes: 6 additions & 0 deletions
6
crates/fluvio-version-manager/fixtures/version/0.10.15/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"channel": { | ||
"tag": "0.10.15" | ||
sehz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
"version": "0.10.15" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
echo "Fluvio Test Executable STABLE" |
4 changes: 4 additions & 0 deletions
4
crates/fluvio-version-manager/fixtures/version/stable/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"channel": "stable", | ||
sehz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"version": "0.10.16" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//! Show Intalled Versions Command | ||
//! | ||
//! The `show` command is responsible of listing all the installed Fluvio Versions | ||
|
||
use anyhow::Result; | ||
use clap::Parser; | ||
use colored::Colorize; | ||
|
||
use fluvio_hub_util::fvm::Channel; | ||
|
||
use crate::common::notify::Notify; | ||
use crate::common::settings::Settings; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct CurrentOpt; | ||
|
||
impl CurrentOpt { | ||
pub async fn process(&self, notify: Notify) -> Result<()> { | ||
let settings = Settings::open()?; | ||
|
||
if let (Some(channel), Some(version)) = (settings.channel, settings.version) { | ||
match channel { | ||
Channel::Latest | Channel::Stable => println!("{} ({})", version, channel), | ||
Channel::Tag(_) => println!("{}", version), | ||
} | ||
} else { | ||
notify.warn("No active version set"); | ||
notify.help(format!( | ||
"You can use {} to set the active version", | ||
"fvm switch".bold() | ||
)); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub mod current; | ||
pub mod install; | ||
pub mod itself; | ||
pub mod show; | ||
pub mod switch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//! Show Intalled Versions Command | ||
//! | ||
//! The `show` command is responsible of listing all the installed Fluvio Versions | ||
|
||
use anyhow::{Result, anyhow}; | ||
use clap::Parser; | ||
use colored::Colorize; | ||
use comfy_table::{Table, Row}; | ||
|
||
use crate::common::manifest::VersionManifest; | ||
use crate::common::notify::Notify; | ||
use crate::common::settings::Settings; | ||
use crate::common::version_directory::VersionDirectory; | ||
use crate::common::workdir::fvm_versions_path; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct ShowOpt; | ||
|
||
impl ShowOpt { | ||
pub async fn process(&self, notify: Notify) -> Result<()> { | ||
let versions_path = fvm_versions_path()?; | ||
|
||
if !versions_path.exists() { | ||
notify.warn("Cannot list installed versions because there are no versions installed"); | ||
notify.help(format!( | ||
"You can install a Fluvio version using the command {}", | ||
"fvm install".bold() | ||
)); | ||
|
||
return Err(anyhow!("No versions installed")); | ||
} | ||
|
||
let settings = Settings::open()?; | ||
let (manifests, maybe_active) = | ||
VersionDirectory::scan_versions_manifests(versions_path, settings.channel)?; | ||
|
||
if manifests.is_empty() && maybe_active.is_none() { | ||
notify.warn("No installed versions found"); | ||
notify.help(format!( | ||
"You can install a Fluvio version using the command {}", | ||
"fvm install".bold() | ||
)); | ||
|
||
return Ok(()); | ||
} | ||
|
||
Self::render_table(manifests, maybe_active); | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Creates a `Table` and renders it to the terminal. | ||
fn render_table(manifests: Vec<VersionManifest>, maybe_active: Option<VersionManifest>) { | ||
let mut table = Table::new(); | ||
|
||
table.set_header(Row::from([" ", "CHANNEL", "VERSION"])); | ||
|
||
if let Some(active) = maybe_active { | ||
table.add_row(Row::from([ | ||
"✓".to_string(), | ||
active.channel.to_string(), | ||
active.version.to_string(), | ||
])); | ||
} | ||
|
||
let mut sorted_manifests = manifests; | ||
sorted_manifests.sort_by(|a, b| b.channel.cmp(&a.channel)); | ||
|
||
for manifest in sorted_manifests { | ||
table.add_row(Row::from([ | ||
" ".to_string(), | ||
manifest.channel.to_string(), | ||
manifest.version.to_string(), | ||
])); | ||
} | ||
|
||
table.load_preset(comfy_table::presets::NOTHING); | ||
|
||
println!("{}", table); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update test to validate tags support.