Skip to content

Commit 496ee5c

Browse files
committed
autocomplete improvements
Signed-off-by: Chris Snow <[email protected]>
1 parent 7fd13b2 commit 496ee5c

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

bin/cli.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -1249,11 +1249,19 @@ def bash(self,):
12491249
12501250
COMP_WORDS_AS_STRING=$(IFS=. ; echo "${COMP_WORDS[*]}")
12511251
1252+
if echo "${prev}" | grep -q '\-\-.*file$'
1253+
then
1254+
CUR_PARAM_IS_FILE=1
1255+
else
1256+
CUR_PARAM_IS_FILE=0
1257+
fi
1258+
12521259
{% raw %}
12531260
for (( idx=${#COMP_WORDS[@]}-1 ; idx>=0 ; idx-- )) ; do
12541261
item="${COMP_WORDS[idx]}"
12551262
if [[ "${item:0:2}" == "--" ]]; then
1256-
if [[ "${item}" == "--columns" ]]; then
1263+
if [[ "${item}" == "--columns" ]]
1264+
then
12571265
LAST_PARAM_IS_COLUMNS=1
12581266
else
12591267
LAST_PARAM_IS_COLUMNS=0
@@ -1276,14 +1284,20 @@ def bash(self,):
12761284
then
12771285
{% set column_names = " ".join(columns[module_name]) %}
12781286
{% set param_names_without_columns = param_names.replace("--columns", "") %}
1279-
COMPREPLY=( $(compgen -W "{{column_names}} {{param_names_without_columns}}" -- $cur) )
1287+
COMPREPLY=( $(compgen -W "{{column_names}}" -- $cur) )
1288+
COMPREPLY+=( $(compgen -W "{{param_names_without_columns}}" -- $cur) )
12801289
else
12811290
COMPREPLY=( $(compgen -W "{{param_names}}" -- $cur) )
12821291
fi
12831292
;;
12841293
{% else %}
12851294
*"hpecp.{{module_name}}.{{function_name}}"*)
1286-
COMPREPLY=( $(compgen -W "{{param_names}}" -- $cur) )
1295+
if [[ $CUR_PARAM_IS_FILE == 1 ]]
1296+
then
1297+
COMPREPLY=( $(compgen -W "$(ls)" -- $cur) )
1298+
else
1299+
COMPREPLY=( $(compgen -W "{{param_names}}" -- $cur) )
1300+
fi
12871301
;;
12881302
{% endif %}
12891303
{% endfor %}

cli_dev.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -x
4+
set -e
5+
6+
pip install -e .
7+
8+
hpecp autocomplete bash > ~/hpecp_completion.sh
9+
10+
source ~/hpecp_completion.sh

0 commit comments

Comments
 (0)