From 61388cff02edd6c3471e73b589b6ce2fd56648c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branislav=20=C5=A0ott?= Date: Wed, 28 Sep 2016 00:17:24 +0200 Subject: [PATCH] Add completions for ninja build system --- share/completions/ninja.fish | 10 ++++++++++ share/functions/__fish_print_ninja_targets.fish | 5 +++++ share/functions/__fish_print_ninja_tools.fish | 6 ++++++ 3 files changed, 21 insertions(+) create mode 100644 share/completions/ninja.fish create mode 100644 share/functions/__fish_print_ninja_targets.fish create mode 100644 share/functions/__fish_print_ninja_tools.fish diff --git a/share/completions/ninja.fish b/share/completions/ninja.fish new file mode 100644 index 000000000..759018a60 --- /dev/null +++ b/share/completions/ninja.fish @@ -0,0 +1,10 @@ +complete -c ninja -f -a '(__fish_print_ninja_targets)' -d Target +complete -x -c ninja -s t -x -a "(__fish_print_ninja_tools)" -d Tools +complete -x -c ninja -s C -x -a "(__fish_complete_directories (commandline -ct))" -d "Change to DIR" +complete -c ninja -s f -x -d "specify build file" +complete -f -c ninja -s n -d "dry run" +complete -f -c ninja -s v -d "show all command lines while building" +complete -f -c ninja -s j -d "number of jobs" +complete -f -c ninja -s l -d "do not start if load > N" +complete -f -c ninja -s k -d "keep until N jobs fail" +complete -f -c ninja -s h -d "help" diff --git a/share/functions/__fish_print_ninja_targets.fish b/share/functions/__fish_print_ninja_targets.fish new file mode 100644 index 000000000..d5456f932 --- /dev/null +++ b/share/functions/__fish_print_ninja_targets.fish @@ -0,0 +1,5 @@ +function __fish_print_ninja_targets + if [ -f build.ninja ] + ninja -t targets 2> /dev/null | string replace -r ':.*' '' + end +end diff --git a/share/functions/__fish_print_ninja_tools.fish b/share/functions/__fish_print_ninja_tools.fish new file mode 100644 index 000000000..385c91edc --- /dev/null +++ b/share/functions/__fish_print_ninja_tools.fish @@ -0,0 +1,6 @@ +function __fish_print_ninja_tools + echo list + if [ -f build.ninja ] + ninja -t list | string match -v '*:' | string replace -r '\s+(\w+).*' '$1' + end +end