Completions: Add namespace completion
Fish will now suggest namespaces if we use one of the subcommands `ls`,
`get` or `set`.
@@ -13,6 +13,10 @@ function __fish_kdb_no_subcommand -d 'Check if the current commandline buffer do
not __input_includes (__fish_kdb_print_subcommands)
end
+function __fish_kdb_needs_namespace -d 'Check if the current command needs a namespace completion'
+ __input_includes ls get set
+end
+
function __fish_kdb_print_subcommands -d 'Print a list of kdb subcommands'
set -l commands (kdb list-commands $argv)
if contains -- $argv -v
@@ -21,6 +25,12 @@ function __fish_kdb_print_subcommands -d 'Print a list of kdb subcommands'
printf '%s\n' $commands
end
+function __fish_kdb_print_namespaces -d 'Print a list of possible namespace completions'
+ set -l namespace (commandline -ct)
+ kdb complete --max-depth=1 "$namespace"
+end
+
# -- Completions ---------------------------------------------------------------------------------------------------------------------------
complete -c kdb -n '__fish_kdb_no_subcommand' -x -a '(__fish_kdb_print_subcommands -v)'
+complete -c kdb -n '__fish_kdb_needs_namespace' -x -a '(__fish_kdb_print_namespaces)'
