From 1613141e8532e2ec5f7b0eabb30299fe21a42675 Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 25 Aug 2023 13:42:09 +0800 Subject: [PATCH] refactor: rename ARGC_FILTER to ARGC_CWORD --- src/compgen.rs | 2 +- tests/compgen.rs | 6 +++--- .../integration__compgen__assing_option_value.snap | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compgen.rs b/src/compgen.rs index 26fcd172..0055f7e2 100644 --- a/src/compgen.rs +++ b/src/compgen.rs @@ -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)); diff --git a/tests/compgen.rs b/tests/compgen.rs index f6506da6..5d115103 100644 --- a/tests/compgen.rs +++ b/tests/compgen.rs @@ -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' } "; @@ -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 :; diff --git a/tests/snapshots/integration__compgen__assing_option_value.snap b/tests/snapshots/integration__compgen__assing_option_value.snap index 95d4b583..31657525 100644 --- a/tests/snapshots/integration__compgen__assing_option_value.snap +++ b/tests/snapshots/integration__compgen__assing_option_value.snap @@ -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 @@ -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 @@ -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