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

Loading…
Cancel
Save