aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2017-05-09 16:06:35 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-05-09 16:12:22 -0400
commit3255cd93dd46fee8f106a6556b1114f773085a2f (patch)
tree711dfe30c3ce7508f183d86310841cbf41cffa08
parent91f5771c3cb04f2aa396ab0c54abb1d4b3403de9 (diff)
downloadtrace-cmd-3255cd93dd46fee8f106a6556b1114f773085a2f.tar.gz
trace-cmd: Have bash completions look at all options by default
Have all the trace-cmd commands have their options looked at for completion, even if there is not a specific function to handle them. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--trace-cmd.bash47
1 files changed, 38 insertions, 9 deletions
diff --git a/trace-cmd.bash b/trace-cmd.bash
index 40c14718..1613c170 100644
--- a/trace-cmd.bash
+++ b/trace-cmd.bash
@@ -9,6 +9,16 @@ show_instances()
return 0
}
+cmd_options()
+{
+ local type="$1"
+ local cur="$2"
+ local flags="$3"
+ local cmds=$(trace-cmd $type -h 2>/dev/null|grep "^ *-" | \
+ sed -e 's/ *\(-[^ ]*\).*/\1/')
+ COMPREPLY=( $(compgen $flags -W "${cmds}" -- "${cur}") )
+}
+
__trace_cmd_list_complete()
{
local prev=$1
@@ -53,9 +63,7 @@ __trace_cmd_show_complete()
show_instances "$cur"
;;
*)
- local cmds=$(trace-cmd show -h 2>/dev/null|grep "^ *-" | \
- sed -e 's/ *\(-[^ ]*\).*/\1/')
- COMPREPLY=( $(compgen -W "${cmds}" -- "${cur}") )
+ cmd_options show "$cur"
;;
esac
}
@@ -68,11 +76,14 @@ __trace_cmd_extract_complete()
local words=("$@")
case "$prev" in
+ extract)
+ cmd_options "$prev" "$cur" -f
+ ;;
-B)
show_instances "$cur"
;;
*)
- COMPREPLY=( $(compgen -f -- "${cur}") )
+ COMPREPLY=( $(compgen -f -- "$cur") )
;;
esac
}
@@ -112,12 +123,31 @@ __trace_cmd_record_complete()
show_instances "$cur"
;;
*)
- # By default, we list files
- COMPREPLY=( $(compgen -f -- "$cur") )
- ;;
+ # stream start and profile do not show all options
+ cmd_options record "$cur" -f
+ ;;
esac
}
+__show_command_options()
+{
+ local command="$1"
+ local cur="$2"
+ local cmds=( $(trace-cmd --help 2>/dev/null | \
+ grep " - " | sed 's/^ *//; s/ -.*//') )
+
+ for cmd in ${cmds[@]}; do
+ if [ $cmd == "$command" ]; then
+ local opts=$(trace-cmd $cmd -h 2>/dev/null|grep "^ *-" | \
+ sed -e 's/ *\(-[^ ]*\).*/\1/')
+ # By default, we list files
+ COMPREPLY=( $(compgen -f -W "${opts}" -- "$cur") )
+ return 0
+ fi
+ done
+ COMPREPLY=( $(compgen -f -- "$cur") )
+}
+
_trace_cmd_complete()
{
local cur=""
@@ -172,8 +202,7 @@ _trace_cmd_complete()
return 0
;;
*)
- # By default, we list files
- COMPREPLY=( $(compgen -f -- "$cur") )
+ __show_command_options "$w" "${cur}"
;;
esac
}