mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
fix help bash completions so they don't repeat parsers
This commit is contained in:
@ -31,6 +31,26 @@ _jc()
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# if jc_help_options and a parser are found anywhere in the line, then no more completions
|
||||||
|
if
|
||||||
|
(
|
||||||
|
for i in "$${words[@]}"; do
|
||||||
|
if [[ " $${jc_help_options[*]} " =~ " $${i} " ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
) && (
|
||||||
|
for i in "$${words[@]}"; do
|
||||||
|
if [[ " $${jc_parsers[*]} " =~ " $${i} " ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
); then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
# if jc_help_options are found anywhere in the line, then only complete with parsers
|
# if jc_help_options are found anywhere in the line, then only complete with parsers
|
||||||
for i in "$${words[@]}"; do
|
for i in "$${words[@]}"; do
|
||||||
if [[ " $${jc_help_options[*]} " =~ " $${i} " ]]; then
|
if [[ " $${jc_help_options[*]} " =~ " $${i} " ]]; then
|
||||||
@ -55,10 +75,10 @@ _jc()
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# if a parser arg is found anywhere in the line, only show options
|
# if a parser arg is found anywhere in the line, only show options and help options
|
||||||
for i in "$${words[@]}"; do
|
for i in "$${words[@]}"; do
|
||||||
if [[ " $${jc_parsers[*]} " =~ " $${i} " ]]; then
|
if [[ " $${jc_parsers[*]} " =~ " $${i} " ]]; then
|
||||||
COMPREPLY=( $$( compgen -W "$${jc_options[*]}" \\
|
COMPREPLY=( $$( compgen -W "$${jc_options[*]} $${jc_help_options[*]}" \\
|
||||||
-- "$${cur}" ) )
|
-- "$${cur}" ) )
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user