Skip to content

Commit

Permalink
fix(extension): when executing ext, allow params with hyphens (#3231)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Nowak-Liebiediew authored Jul 11, 2023
1 parent 8f7610e commit 2b08415
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions e2e/tests-dfx/extension.bash
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,44 @@ echo testoutput' > "$CACHE_DIR"/extensions/test_extension/test_extension
assert_match 'No extensions installed'
}


@test "run with hyphened parameters" {
CACHE_DIR=$(dfx cache show)
mkdir -p "$CACHE_DIR"/extensions/test_extension

cat > "$CACHE_DIR"/extensions/test_extension/test_extension << "EOF"
#!/usr/bin/env bash
if [ "$2" == "--the-param" ]; then
echo "pamparam the param is $3"
fi
EOF

chmod +x "$CACHE_DIR"/extensions/test_extension/test_extension

cat > "$CACHE_DIR"/extensions/test_extension/extension.json <<EOF
{
"name": "test_extension",
"version": "0.1.0",
"homepage": "https://github.com/dfinity/dfx-extensions",
"authors": "DFINITY",
"summary": "Test extension for e2e purposes.",
"categories": [],
"keywords": [],
"subcommands": {
"abc": {
"about": "something something",
"args": {
"the_param": {
"about": "this is the param",
"long": "the-param"
}
}
}
}
}
EOF

assert_command dfx test_extension abc --the-param 123
assert_eq "pamparam the param is 123"
}
1 change: 1 addition & 0 deletions src/dfx/src/commands/extension/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct RunOpts {
/// Specifies the name of the extension to run.
name: OsString,
/// Specifies the parameters to pass to the extension.
#[arg(allow_hyphen_values = true)]
params: Vec<OsString>,
}

Expand Down

0 comments on commit 2b08415

Please sign in to comment.