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
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion forc/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub async fn run_cli() -> ForcResult<()> {
Forc::ContractId(command) => contract_id::exec(command),
Forc::PredicateRoot(command) => predicate_root::exec(command),
Forc::Plugin(args) => {
let output = plugin::execute_external_subcommand(args)?;
let output = plugin::execute_external_subcommand(args, opt.verbose > 0)?;
let code = output
.status
.code()
Expand Down
23 changes: 22 additions & 1 deletion forc/src/cli/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,35 @@ use std::{
///
/// E.g. given `foo bar baz` where `foo` is an unrecognized subcommand to `forc`, tries to execute
/// `forc-foo bar baz`.
pub(crate) fn execute_external_subcommand(args: Vec<String>) -> Result<process::Output> {
pub(crate) fn execute_external_subcommand(
args: Vec<String>,
is_verbose: bool,
) -> Result<process::Output> {
let cmd = args.get(0).expect("`args` must not be empty");
let args = &args[1..];
let path = find_external_subcommand(cmd);
let command = match path {
Some(command) => command,
None => bail!("no such subcommand: `{}`", cmd),
};

if let Ok(forc_path) = std::env::current_exe() {
kayagokalp marked this conversation as resolved.
Show resolved Hide resolved
if is_verbose && command.parent() != forc_path.parent() {
crodas marked this conversation as resolved.
Show resolved Hide resolved
let bold_yellow_code = "\x1b[1;33m";
crodas marked this conversation as resolved.
Show resolved Hide resolved
let bold_white_code = "\x1b[1;37m";
let reset_code = "\x1b[0m";
eprintln!(
"{}WARNING:{} The {} ({}) plugin is in a different directory than forc ({}){}\n",
bold_yellow_code,
bold_white_code,
cmd,
command.display(),
forc_path.display(),
reset_code,
);
}
}

let output = process::Command::new(command)
.stdin(process::Stdio::inherit())
.stdout(process::Stdio::inherit())
Expand Down
Loading