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

Make sure that list of plugins is sorted and unique #5395

Merged
merged 15 commits into from
Jan 3, 2024
Merged
Changes from 1 commit
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
27 changes: 20 additions & 7 deletions forc/src/cli/commands/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,32 @@ pub struct Command {
describe: bool,
}

fn get_file_name(path: &Path) -> String {
crodas marked this conversation as resolved.
Show resolved Hide resolved
path.file_name()
.expect("Failed to read file name")
.to_str()
.expect("Failed to print file name")
.to_string()
}

pub(crate) fn exec(command: PluginsCommand) -> ForcResult<()> {
let PluginsCommand {
print_full_path,
describe,
} = command;

let mut plugins = crate::cli::plugin::find_all()
.map(|path| {
print_plugin(path.clone(), print_full_path, describe)
.map(|info| (get_file_name(&path), info))
})
.collect::<Result<Vec<_>, _>>()?;
plugins.sort_by(|a, b| a.0.cmp(&b.0));
plugins.dedup_by(|a, b| a.0 == b.0);
crodas marked this conversation as resolved.
Show resolved Hide resolved
crodas marked this conversation as resolved.
Show resolved Hide resolved

info!("Installed Plugins:");
for path in crate::cli::plugin::find_all() {
info!("{}", print_plugin(path, print_full_path, describe)?);
for plugin in plugins {
info!("{}", plugin.1);
}
Ok(())
}
Expand Down Expand Up @@ -72,11 +89,7 @@ fn format_print_description(
let display = if print_full_path {
path.display().to_string()
} else {
path.file_name()
.expect("Failed to read file name")
.to_str()
.expect("Failed to print file name")
.to_string()
get_file_name(&path)
};

let description = parse_description_for_plugin(&path);
Expand Down
Loading