Skip to content

Commit

Permalink
refactor: rename ARGC_FILTER to ARGC_CWORD
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Aug 25, 2023
1 parent f62324c commit 1613141
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/compgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn compgen(
let mut envs = HashMap::new();
envs.insert("ARGC_COMPGEN".into(), "1".into());
envs.insert("ARGC_OS".into(), env::consts::OS.to_string());
envs.insert("ARGC_FILTER".into(), argc_filter.clone());
envs.insert("ARGC_CWORD".into(), argc_filter.clone());
envs.insert("ARGC_LAST_ARG".into(), last_arg.to_string());
if let Some(cwd) = get_current_dir() {
envs.insert("ARGC_PWD".into(), escape_shell_words(&cwd));
Expand Down
6 changes: 3 additions & 3 deletions tests/compgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ fn assing_option_value() {
# @arg val[`_choice_fn`]
_choice_fn() {
echo __argc_filter=
( set -o posix ; set ) | grep 'argc_\|ARGC_COMPGEN\|ARGC_FILTER\|ARGC_LAST_ARG\|ARGC_VARS'
( set -o posix ; set ) | grep 'argc_\|ARGC_COMPGEN\|ARGC_CWORD\|ARGC_LAST_ARG\|ARGC_VARS'
}
";

Expand Down Expand Up @@ -840,8 +840,8 @@ fn filter_quote() {
let script = r#"
# @arg args[`_choice_fn`]
_choice_fn() {
echo "__argc_prefix=${ARGC_FILTER%%=*}="
echo "__argc_filter=${ARGC_FILTER#*=}"
echo "__argc_prefix=${ARGC_CWORD%%=*}="
echo "__argc_filter=${ARGC_CWORD#*=}"
echo foo
echo bar
:;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: data
************ COMPGEN `prog --oa=abc` ************
__argc_filter= /color:green
ARGC_COMPGEN=1 /color:green
ARGC_FILTER=abc /color:green
ARGC_CWORD=abc /color:green
ARGC_LAST_ARG=--oa=abc /color:green
ARGC_VARS=YXJnY19vYT1hYmM7YXJnY19fYXJncz0oIHByb2cgJy0tb2E9YWJjJyApO2FyZ2NfX2NtZF9hcmdfaW5kZXg9MDthcmdjX19wb3NpdGlvbmFscz0oICApOw== /color:green
argc__args=([0]="prog" [1]="--oa=abc") /color:green
Expand All @@ -16,7 +16,7 @@ argc_oa=abc /color:green
************ COMPGEN `prog oa=abc` ************
__argc_filter= /color:green
ARGC_COMPGEN=1 /color:green
ARGC_FILTER=oa=abc /color:green
ARGC_CWORD=oa=abc /color:green
ARGC_LAST_ARG=oa=abc /color:green
ARGC_VARS=YXJnY192YWw9J29hPWFiYyc7YXJnY19fYXJncz0oIHByb2cgJ29hPWFiYycgKTthcmdjX19jbWRfYXJnX2luZGV4PTA7YXJnY19fcG9zaXRpb25hbHM9KCAnb2E9YWJjJyApOw== /color:green
argc__args=([0]="prog" [1]="oa=abc") /color:green
Expand All @@ -27,7 +27,7 @@ argc_val=oa=abc /color:green
************ COMPGEN `prog -- --oa=abc` ************
__argc_filter= /color:green
ARGC_COMPGEN=1 /color:green
ARGC_FILTER=--oa=abc /color:green
ARGC_CWORD=--oa=abc /color:green
ARGC_LAST_ARG=--oa=abc /color:green
ARGC_VARS=YXJnY192YWw9Jy0tb2E9YWJjJzthcmdjX19hcmdzPSggcHJvZyAtLSAnLS1vYT1hYmMnICk7YXJnY19fY21kX2FyZ19pbmRleD0wO2FyZ2NfX2Rhc2hlcz0wO2FyZ2NfX3Bvc2l0aW9uYWxzPSggJy0tb2E9YWJjJyApOw== /color:green
argc__args=([0]="prog" [1]="--" [2]="--oa=abc") /color:green
Expand Down

0 comments on commit 1613141

Please sign in to comment.