| 1 | #compdef gammaray |
| 2 | |
| 3 | # This file is part of GammaRay, the Qt application inspection and manipulation tool. |
| 4 | # |
| 5 | # SPDX-FileCopyrightText: 2013 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> |
| 6 | # Author: ivan tkachenko <[email protected]> |
| 7 | # |
| 8 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 9 | # |
| 10 | # Contact KDAB at <[email protected]> for commercial licensing options. |
| 11 | # |
| 12 | |
| 13 | function _gammaray-probescip-shell shell gammaray 3.4.0-1 _gammaray-probe().() { |
| 14 | local -a probes names descriptions |
| 15 | |
| 16 | probes=( ${(f)"$(_call_program gammaray-probes $service --list-probes)"} ) |
| 17 | names=( ${probes%% *} ) |
| 18 | descriptions=( ${${probes#* \(}%\)} ) |
| 19 | |
| 20 | _describe -t probe 'probe' \ |
| 21 | descriptions names |
| 22 | } |
| 23 | |
| 24 | function _gammaray-injectorscip-shell shell gammaray 3.4.0-1 _gammaray-injector().() { |
| 25 | local -a injectors=( gdb lldb style preload windll ) |
| 26 | local expl |
| 27 | |
| 28 | _wanted injector expl 'injector' \ |
| 29 | compadd -- $injectors |
| 30 | } |
| 31 | |
| 32 | function _gammaray-listenscip-shell shell gammaray 3.4.0-1 _gammaray-listen().() { |
| 33 | local -a addresses=( 'tcp://0.0.0.0' 'tcp://[::]' ) |
| 34 | local expl |
| 35 | |
| 36 | if (( $+commands[ip] && $+commands[jq] )); then |
| 37 | addresses+=( ${(f)"$( |
| 38 | ip -j a | |
| 39 | jqscip-shell system . . jq. --raw-output ' |
| 40 | .[].addr_info[] | |
| 41 | if .family == "inet" |
| 42 | then "tcp://\(.local)" |
| 43 | elif .family == "inet6" |
| 44 | then "tcp://[\(.local)]" |
| 45 | else null end |
| 46 | ' |
| 47 | )"} ) |
| 48 | else |
| 49 | addresses+=( 'tcp://127.0.0.1' ) |
| 50 | fi |
| 51 | |
| 52 | # sanitize special characters |
| 53 | addresses=( ${addresses//:/\:} ) |
| 54 | |
| 55 | _wanted address expl 'address' \ |
| 56 | compadd -- $addresses |
| 57 | } |
| 58 | |
| 59 | function _gammaray-host-portscip-shell shell gammaray 3.4.0-1 _gammaray-host-port().() { |
| 60 | if compset -P '*://*:' ; then |
| 61 | _numbers -t port port |
| 62 | elif compset -P '*://' ; then |
| 63 | _hosts -qS: |
| 64 | else |
| 65 | compadd -S "" 'tcp://' |
| 66 | fi |
| 67 | } |
| 68 | |
| 69 | _arguments \ |
| 70 | '(* -)--list-probes[list all installed probes]' \ |
| 71 | '--probe[specify which probe to use]:abi:_gammaray-probe' \ |
| 72 | '(-i --injector)'{-i,--injector}'[set injection type]:injector:_gammaray-injector' \ |
| 73 | '--self-test[run self tests, of everything or the specified injector]::injector:_gammaray-injector' \ |
| 74 | '(-o --injector-override)'{-o,--injector-override}'[Override the injector executable if handled (requires -i/--injector)]:executable: _command_names -e' \ |
| 75 | "--inject-only[only inject the probe, don't show the UI]" \ |
| 76 | '(--inprocess --listen)--inprocess[use in-process UI]' \ |
| 77 | '(--inprocess --listen --no-listen)--listen[specify the address the server should listen on]:address:_gammaray-listen' \ |
| 78 | '(--inprocess --listen --no-listen)--no-listen[disables remote access entirely (implies --inprocess)]' \ |
| 79 | - '(H)' \ |
| 80 | '(* -)'{-h,--help}'[print program help and exit]' \ |
| 81 | '(* -)'{-v,--version}'[print program version and exit]' \ |
| 82 | - pid \ |
| 83 | '--pid[attach to running Qt application]:pid:_pids' \ |
| 84 | - connect \ |
| 85 | '--connect[connect to an already injected target]:host[\:port]:_gammaray-host-port' \ |
| 86 | - application \ |
| 87 | ':program: _command_names -e' \ |
| 88 | '*::program arguments: _normal' |