3 # Copyright (c) 2015-2023 Philippe Proulx <eeppeliteloop@gmail.com>
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 # This is a Zsh completion function for the lttng-crash(1) command (see
26 # <https://lttng.org/>), for versions 2.7 to 2.14.
28 # If you want, at your own risk, the function to work with versions
29 # above 2.14, set `LTTNG_ZSH_COMP_IGNORE_VERSION_LIMIT=1`.
31 # Sets the `minor_version` variable to the minor version of LTTng-tools,
32 # or to `0` if not found.
33 __lttng_set_minor_version() {
38 if [[ $($words[1] --version) =~ '[[:blank:]]+2\.([[:digit:]]+)' ]]; then
39 minor_version=$match[1]
43 # Adds completions for the arguments of the `lttng-crash` command.
44 __lttng_complete_lttng_crash() {
45 local curcontext=$curcontext state state_descr line
48 '*'{-v,--verbose}'[increase verbosity]'
49 '(- : *)'{-V,--version}'[show version and quit]'
50 '(- : *)'{-h,--help}'[show help]'
51 '(-x --extract)'{-x+,--extract=}'[set the path of the directory where to extract the trace]:trace extraction directory path:_directories'
52 '(-e --viewer)'{-e+,--viewer=}'[set the trace reader command]:trace reader command:_files'
53 '1:shared memory directory:_directories'
56 _arguments -C -s -w : $specs
59 # First, set the `minor_version` variable to the minor version of
60 # LTTng-tools. Some features depend on a specific version and this
61 # completion function supports many versions from LTTng-tools 2.7.
62 local -i minor_version
64 __lttng_set_minor_version
66 # Exit now with LTTng-tools < 2.7 or LTTng-tools > 2.14
67 local -r ignore_version_limit=${LTTNG_ZSH_COMP_IGNORE_VERSION_LIMIT:-0}
69 if ((minor_version < 7 || (minor_version > 14 && !ignore_version_limit))); then
70 _message "completion not available for LTTng-tools 2.$minor_version; please update the completion files or set \`LTTNG_ZSH_COMP_IGNORE_VERSION_LIMIT=1\`"
74 # Add completions for lttng-crash(1)
75 __lttng_complete_lttng_crash "$@"