Skip to content
Open
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
34 changes: 31 additions & 3 deletions src/commands/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,11 @@ pub struct List {
#[clap(long, group = "which")]
pub installed: bool,

/// List all versions of plugins. This is the default behaviour.
/// List all versions of plugins.
#[clap(long, group = "which")]
pub all: bool,

/// List latest and installed versions of plugins.
/// List latest and installed versions of plugins. This is the default behaviour.
#[clap(long, group = "which")]
pub summary: bool,

Expand Down Expand Up @@ -798,7 +798,7 @@ impl List {
}
}?;

if self.summary {
if self.should_summarise() {
plugins = summarise(plugins);
}

Expand Down Expand Up @@ -851,6 +851,10 @@ impl List {
fn target_environment(&self) -> OptionalValueFlag {
(&self.target_environment).into()
}

fn should_summarise(&self) -> bool {
self.summary || (!self.installed && !self.all)
}
}

/// Search for plugins by name.
Expand Down Expand Up @@ -1192,4 +1196,28 @@ mod test {
assert!(rest_vers.contains("1.2.3"));
assert!(rest_vers.contains("1.3.5"));
}

#[test]
fn list_installed_disables_summary_mode() {
let list = List::parse_from(["list", "--installed"]);
assert!(!list.should_summarise());
}

#[test]
fn list_default_enables_summary_mode() {
let list = List::parse_from(["list"]);
assert!(list.should_summarise());
}

#[test]
fn list_all_disables_summary_mode() {
let list = List::parse_from(["list", "--all"]);
assert!(!list.should_summarise());
}

#[test]
fn list_summary_enables_summary_mode() {
let list = List::parse_from(["list", "--summary"]);
assert!(list.should_summarise());
}
}
Loading