Clean-up: consumer.hpp: coding style indentation fix
[lttng-tools.git] / extras / zsh-completion / _lttng-relayd
1 #compdef lttng-relayd
2 #
3 # Copyright (c) 2015-2023 Philippe Proulx <eeppeliteloop@gmail.com>
4 #
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:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
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
21 # THE SOFTWARE.
22 #
23 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24 #
25 # This is a Zsh completion function for the lttng-relayd(1) command
26 # (see <https://lttng.org/>), for versions 2.5 to 2.14.
27 #
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`.
30
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() {
34 minor_version=0
35
36 local -a match
37
38 if [[ $($words[1] --version) =~ '2\.([[:digit:]]+)' ]]; then
39 minor_version=$match[1]
40 fi
41 }
42
43 # Adds completions for the arguments of the `lttng-relayd` command.
44 __lttng_complete_lttng_relayd() {
45 local curcontext=$curcontext state state_descr line
46 local -A opt_args
47
48 # LTTng-tools 2.5+
49 local specs=(
50 '*'{-v,--verbose}'[increase verbosity]'
51 '(- : *)'{-V,--version}'[show version and quit]'
52 '(- : *)'{-h,--help}'[show help]'
53 '(-d --daemonize -b --background)'{-d,--daemonize}'[start as daemon and close file descriptors (console)]'
54 '(-b --background -d --daemonize)'{-b,--background}'[start as daemon, but keep file descriptors (console) open]'
55 '(-C --control-port)'{-C+,--control-port=}'[set the control port URL]:control port URL: '
56 '(-D --data-port)'{-D+,--data-port=}'[set the data port URL]:data port URL: '
57 '(-L --live-port)'{-L+,--live-port=}'[set the live port URL]:live port URL: '
58 '(-o --output)'{-o+,--output=}'[set the trace output directory path]:trace output directory path:_directories'
59 '(-g --group)'{-g+,--group=}'[set the Unix tracing group name]:Unix tracing group name:_groups'
60 '(-f --config)'{-f+,--config=}'[set the path to the INI daemon configuration file]:configuration file path:_files'
61 )
62
63 # LTTng-tools 2.12+
64 if ((minor_version >= 12)); then
65 specs+=(
66 '(--fd-pool-size)--fd-pool-size=[set the size of the file descriptor pool]:file descriptor pool size: '
67 '(-w --working-directory)'{-w+,--working-directory=}'[set the working directory of the processes `lttng-relayd` creates]:working directory:_directories'
68 '(-p --group-output-by-host -s --group-output-by-session)'{-p,--group-output-by-host}'[group the written trace directories by hostname]'
69 '(-p --group-output-by-host -s --group-output-by-session)'{-s,--group-output-by-session}'[group the written trace directories by recording session name]'
70 '(-x --disallow-clear)'{-x,--disallow-clear}'[disallow clearing operations]'
71 )
72 fi
73
74 _arguments -C -s -w : $specs
75 }
76
77 # First, set the `minor_version` variable to the minor version of
78 # LTTng-tools. Some features depend on a specific version and this
79 # completion function supports many versions from LTTng-tools 2.5.
80 local -i minor_version
81
82 __lttng_set_minor_version
83
84 # Exit now with LTTng-tools < 2.5 or LTTng-tools > 2.14
85 local -r ignore_version_limit=${LTTNG_ZSH_COMP_IGNORE_VERSION_LIMIT:-0}
86
87 if ((minor_version < 5 || (minor_version > 14 && !ignore_version_limit))); then
88 _message "completion not available for LTTng-tools 2.$minor_version; please update the completion files or set \`LTTNG_ZSH_COMP_IGNORE_VERSION_LIMIT=1\`"
89 return 1
90 fi
91
92 # Add completions for lttng-relayd(1)
93 __lttng_complete_lttng_relayd "$@"
This page took 0.030162 seconds and 4 git commands to generate.