Skip to content

Commit 2294bb8

Browse files
authored
[tools] Add bash autocomplete script for iree-opt/iree-compile (iree-org#22424)
1 parent ce3b639 commit 2294bb8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# Include this script in your shell PATH to enable argument completion for IREE
4+
# tools.
5+
6+
_iree_tools_autocomplete() {
7+
local tool="$1"
8+
local commands
9+
local cur
10+
11+
# Get the list of commands from the appropriate tool's `--help-list`
12+
commands=$($tool --help-list | awk '{print $1}' | grep -v '^ *=' | sed 's/[=<].*//')
13+
14+
cur=${COMP_WORDS[COMP_CWORD]}
15+
16+
case "$cur" in
17+
-*)
18+
COMPREPLY=($(compgen -W "$commands" -- "${cur}"))
19+
;;
20+
*)
21+
COMPREPLY=($(compgen -f -- "${cur}"))
22+
;;
23+
esac
24+
25+
return 0
26+
}
27+
28+
# Register the completion function for iree-opt
29+
complete -F _iree_tools_autocomplete iree-opt
30+
# Register the completion function for iree-compile
31+
complete -F _iree_tools_autocomplete iree-compile

0 commit comments

Comments
 (0)