File indexing completed on 2024-05-19 05:38:32

0001 #compdef krunner
0002 
0003 # SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0004 #
0005 # SPDX-License-Identifier: GPL-2.0-or-later
0006 
0007 function _krunner_runners() {
0008   local -a runners lines split
0009   local line
0010 
0011   # Fetch list, strip header, split by lines
0012   lines=( ${(f)"$(_call_program krunner-runners krunner --list | tail -n +3)"} )
0013 
0014   for line in ${lines[@]}; do
0015     # Split by ": " (including whitespace) and swap the order to the format expected by _describe
0016     split=( ${(s/: /)line} )
0017     runners+=( "${split[2]}:${split[1]}" )
0018   done
0019 
0020   _describe -t runner 'runner' runners
0021 }
0022 
0023 local ret=1
0024 
0025 _arguments -C \
0026   '(* -)'{-h,--help}'[Displays help on commandline options]' \
0027   '(-c --clipboard)'{-c,--clipboard}'[Use the clipboard contents as query for KRunner]' \
0028   '(-d --daemon)'{-d,--daemon}"[Start KRunner in the background, don't show it]" \
0029   '--replace[Replace an existing instance]' \
0030   '--runner=[Show only results from the given plugin]:runner:_krunner_runners' \
0031   '--list[List available plugins]' \
0032   '*:query:' \
0033   && ret=0
0034 
0035 return $ret