Skip to content

Commit

Permalink
bash,zsh: ensure completion for both pmlogdump and pmdumplog
Browse files Browse the repository at this point in the history
  • Loading branch information
myllynen committed Apr 16, 2024
1 parent 1e9b86a commit 0bb34fd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion qa/1100
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ _check_completion_bash()
cmds="$(grep ' pcp2.*)' $bash_comp | tr -d ')')"
cmds="$cmds $(grep ' pm.*)' $bash_comp | tr -d ')')"
for cmd in $cmds; do
# Handle aliases
str=" $cmd"
[ "$cmd" = "pmlogdump|pmdumplog" ] && cmd=pmdumplog && str=" pmlogdump|pmdumplog"
which $cmd > /dev/null 2>&1 || continue
$skip_pcp2elasticsearch && [ "$cmd" = pcp2elasticsearch ] && continue
$skip_pcp2graphite && [ "$cmd" = pcp2graphite ] && continue
Expand All @@ -104,7 +107,7 @@ _check_completion_bash()
$skip_pmdumptext && [ "$cmd" = pmdumptext ] && continue
$skip_pmrep && [ "$cmd" = pmrep ] && continue
$skip_pmseries && [ "$cmd" = pmseries ] && continue
comps=$(grep -A 1 " $cmd)" $bash_comp | tail -n 1 | sed -e 's,all_args=",,' -e 's,",,')
comps=$(grep -A 1 "$str)" $bash_comp | tail -n 1 | sed -e 's,all_args=",,' -e 's,",,')
# Need $tmp.err and PCP_STDERR for pmchart ...
#
rm -f $tmp.err
Expand Down
5 changes: 4 additions & 1 deletion qa/967
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ _check_completion_zsh()
pytool=$(awk "/common_python=/,/ \)/" $zsh_comp)
pmda=$(awk "/common_pmda=/,/ \)/" $zsh_comp)
version=V
comps=$(awk "/ $cmd\)/,/;;/" $zsh_comp | sed -e 's,equivalent to .*,,')
# Handle aliases
str=" $cmd"
[ "$cmd" = "pmlogdump" -o "$cmd" = "pmdumplog" ] && str=" pmlogdump|pmdumplog"
comps=$(awk "/$str\)/,/;;/" $zsh_comp | sed -e 's,equivalent to .*,,')
# Need $tmp.err and PCP_STDERR for pmchart ...
#
rm -f $tmp.err
Expand Down
4 changes: 2 additions & 2 deletions src/bashrc/pcp_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ _pcp_complete()
all_args="AahnOPSsTtVZz"
arg_regex="-[AahnOSsTtZz]"
;;
pmdumplog)
pmlogdump|pmdumplog)
all_args="adehIiLlMmnrSsTtVvxZz"
arg_regex="-[nSTvZ]"
;;
Expand Down Expand Up @@ -210,4 +210,4 @@ _pcp_complete()
fi
fi
}
complete -F _pcp_complete -o default pcp2elasticsearch pcp2graphite pcp2influxdb pcp2json pcp2spark pcp2xlsx pcp2xml pcp2zabbix pmclient pmdumplog pmdumptext pmevent pmfind pmie pmie2col pmiectl pminfo pmjson pmlc pmlogcheck pmlogctl pmlogextract pmlogger pmloglabel pmlogpaste pmlogreduce pmlogsize pmlogsummary pmprobe pmrep pmseries pmstat pmstore pmval
complete -F _pcp_complete -o default pcp2elasticsearch pcp2graphite pcp2influxdb pcp2json pcp2spark pcp2xlsx pcp2xml pcp2zabbix pmclient pmdumplog pmdumptext pmevent pmfind pmie pmie2col pmiectl pminfo pmjson pmlc pmlogcheck pmlogctl pmlogdump pmlogextract pmlogger pmloglabel pmlogpaste pmlogreduce pmlogsize pmlogsummary pmprobe pmrep pmseries pmstat pmstore pmval
4 changes: 2 additions & 2 deletions src/zshrc/_pcp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#compdef pcp pcp2arrow pcp2elasticsearch pcp2graphite pcp2influxdb pcp2json pcp2spark pcp2xlsx pcp2xml pcp2zabbix pmafm pmchart pmclient pmclient_fg=pmclient pmdbg pmdiff pmdumplog pmdumptext pmerr pmevent=pmval pmfind pmie pmie2col pmiectl=pmlogctl pminfo pmiostat pmjson pmlc pmlogcheck pmlogctl pmlogextract pmlogger pmloglabel pmlogpaste pmlogreduce pmlogsize pmlogsummary pmprobe pmrep pmseries pmstat pmstore pmval
#compdef pcp pcp2arrow pcp2elasticsearch pcp2graphite pcp2influxdb pcp2json pcp2spark pcp2xlsx pcp2xml pcp2zabbix pmafm pmchart pmclient pmclient_fg=pmclient pmdbg pmdiff pmdumplog pmdumptext pmerr pmevent=pmval pmfind pmie pmie2col pmiectl=pmlogctl pminfo pmiostat pmjson pmlc pmlogcheck pmlogctl pmlogdump pmlogextract pmlogger pmloglabel pmlogpaste pmlogreduce pmlogsize pmlogsummary pmprobe pmrep pmseries pmstat pmstore pmval
#
# PCP <https://pcp.io> completions for zsh <http://zsh.sf.net>.
#
Expand Down Expand Up @@ -353,7 +353,7 @@ _pcp () {
'2:archive:->archives' \
&& return 0
;;
pmdumplog)
pmlogdump|pmdumplog)
arch_req=1
_arguments -C -S -s \
"$common_help[@]" \
Expand Down

0 comments on commit 0bb34fd

Please sign in to comment.