summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorAlberto Sartori <alberto.sartori@huawei.com>2022-11-25 13:04:44 +0100
committerAlberto Sartori <alberto.sartori@huawei.com>2022-11-25 13:04:44 +0100
commit72f58b3bc71989fb4805854a2d48fd8f64906b49 (patch)
treed710bd2bfc7fea9f28909765ac5264c317d08223 /share
parent481e69c86c3e33b06d9318e909cabe6de176c5f5 (diff)
downloadjustbuild-72f58b3bc71989fb4805854a2d48fd8f64906b49.tar.gz
bash completion: suppress stderr produced when using -D option...
...and while there, avoid a bit of code duplication
Diffstat (limited to 'share')
-rw-r--r--share/just-mr_complete.bash29
-rw-r--r--share/just_complete.bash2
2 files changed, 3 insertions, 28 deletions
diff --git a/share/just-mr_complete.bash b/share/just-mr_complete.bash
index c8d3f4f1..4fc69f33 100644
--- a/share/just-mr_complete.bash
+++ b/share/just-mr_complete.bash
@@ -35,32 +35,7 @@ if path.exists("$CONF"):
EOF
}
-_just-mr_targets(){
- command -v python3 &>/dev/null || return
- python3 - <<EOF
-from json import load
-from os import path
-
-def print_targets(target_file):
- if not path.exists(target_file):
- return
- with open(target_file) as f:
- targets = load(f)
- for t in targets.keys():
- print(t)
- exit()
-
-def main(prev, name):
- # if prev is a directory, then look for targets there
- if path.isdir(prev):
- print_targets(path.join(prev, name))
-
- # fall back to current directory
- print_targets(name)
-
-main('$1', "TARGETS")
-EOF
-}
+source "${BASH_SOURCE%/*}"/just_complete.bash
_just-mr_completion(){
local readonly SUBCOMMANDS=(setup setup-env fetch update "do" version build analyse describe install-cas install rebuild)
@@ -89,7 +64,7 @@ _just-mr_completion(){
then
# just subcommand options and modules/targets
local _opts=($(_just-mr_options "just $cmd"))
- local _targets=($(_just-mr_targets $prev))
+ local _targets=($(_just_targets $prev 2>/dev/null))
COMPREPLY=($(compgen -f -W "${_opts[*]} ${_targets[*]}" -- $word ))
compopt -o plusdirs -o bashdefault -o default
else
diff --git a/share/just_complete.bash b/share/just_complete.bash
index 51a7e5e3..41f8f5aa 100644
--- a/share/just_complete.bash
+++ b/share/just_complete.bash
@@ -46,7 +46,7 @@ _just_completion(){
elif [[ $cmd =~ ^(build|analyse|describe|install-cas|install|rebuild) ]]
then
local _opts=($(_just_subcommand_options $cmd))
- local _targets=($(_just_targets $prev))
+ local _targets=($(_just_targets $prev 2>/dev/null))
COMPREPLY=($(compgen -f -W "${_opts[*]} ${_targets[*]}" -- $word ))
compopt -o plusdirs -o bashdefault -o default
else