Browse Source

refactors

remotes/origin/list-filter
Ryan Cao 2 years ago
parent
commit
81e6532b26
No known key found for this signature in database
  1. 14
      src/commands/ls_remote.rs

14
src/commands/ls_remote.rs

@ -11,7 +11,7 @@ pub struct LsRemote { @@ -11,7 +11,7 @@ pub struct LsRemote {
#[arg(long)]
filter: Option<UserVersion>,
/// Only show latest LTS versions
/// Show only LTS versions (optionally filter by LTS codename)
#[arg(long)]
lts: Option<Option<String>>,
@ -55,13 +55,8 @@ impl super::command::Command for LsRemote { @@ -55,13 +55,8 @@ impl super::command::Command for LsRemote {
all_versions.retain(|v| filter.matches(&v.version, config));
}
if all_versions.is_empty() {
eprintln!("{}", "No versions were found!".red());
return Ok(());
}
if self.latest {
all_versions = vec![all_versions.into_iter().next().unwrap()];
all_versions.truncate(1);
}
all_versions.sort_by_key(|v| v.version.clone());
@ -69,6 +64,11 @@ impl super::command::Command for LsRemote { @@ -69,6 +64,11 @@ impl super::command::Command for LsRemote {
all_versions.reverse();
}
if all_versions.is_empty() {
eprintln!("{}", "No versions were found!".red());
return Ok(());
}
for version in &all_versions {
print!("{}", version.version);
if let Some(lts) = &version.lts {

Loading…
Cancel
Save