Skip to content

Commit

Permalink
Merge pull request #32909 from arthurzam/bash-v256
Browse files Browse the repository at this point in the history
shell-completion: add more missing args for bash
  • Loading branch information
yuwata committed May 18, 2024
2 parents f3c5ea7 + 27e4974 commit e579017
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions shell-completion/bash/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ items = [['busctl', ''],
['systemd-dissect', 'HAVE_BLKID'],
['systemd-resolve', 'ENABLE_RESOLVE'],
['systemd-sysext', 'ENABLE_SYSEXT'],
['systemd-vmspawn', 'ENABLE_VMSPAWN'],
['timedatectl', 'ENABLE_TIMEDATED']]

foreach item : items
Expand Down
6 changes: 3 additions & 3 deletions shell-completion/bash/systemd-nspawn
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ _systemd_nspawn() {
--keep-unit -n --network-veth -j -x --ephemeral -a --as-pid2 -U --suppress-sync=yes'
[ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro
-M --machine -S --slice -E --setenv -Z --selinux-context -L --selinux-apifs-context
--register --network-interface --network-bridge --personality -i --image --tmpfs
--register --network-interface --network-bridge --personality -i --image --image-policy --tmpfs
--volatile --network-macvlan --kill-signal --template --notify-ready --root-hash --chdir
--pivot-root --property --private-users --private-users-ownership --network-namespace-path
--network-ipvlan --network-veth-extra --network-zone -p --port --system-call-filter --overlay
--overlay-ro --settings --rlimit --hostname --no-new-privileges --oom-score-adjust --cpu-affinity
--resolv-conf --timezone --root-hash-sig --background'
--resolv-conf --timezone --root-hash-sig --background --oci-bundle --verity-data'
)

_init_completion || return

if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--directory|-D|--template)
--directory|-D|--template|--oci-bundle)
compopt -o nospace
comps=$(compgen -S/ -A directory -- "$cur" )
;;
Expand Down
28 changes: 15 additions & 13 deletions shell-completion/bash/systemd-run
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,17 @@ __get_machines() {

_systemd_run() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local OPTS='--no-ask-password --scope -u --unit -p --property --description --slice --slice-inherit
-r --remain-after-exit --send-sighup --service-type --uid --gid --nice
--working-directory -d --same-dir -E --setenv -t --pty -P --pipe -S --shell -q --quiet
--on-active --on-boot --on-startup --on-unit-active --on-unit-inactive --on-calendar
--on-clock-change --on-timezone-change --path-property --socket-property
--timer-property --no-block --wait -G --collect --user --system -H --host -M --machine
-h --help --version'

local mode=--system
local i
local opts_with_values=(
--unit -p --property --slice --description --service-type --uid --gid --nice --working-directory
-E --setenv --on-active --on-boot --on-startup --on-unit-active --on-unit-inactive --on-calendar
--path-property --socket-property --timer-property -H --host -M --machine
--path-property --socket-property --timer-property -H --host -M --machine --expand-environment
--background
)
local OPTS="${opts_with_values[*]} --no-ask-password --scope -u --slice-inherit -r --remain-after-exit
--send-sighup -d --same-dir -t --pty -P --pipe -S --shell -q --quiet --ignore-failure
--on-clock-change --on-timezone-change --no-block --wait -G --collect --user --system -h --help --version"
local mode=--system
local i
for (( i=1; i <= COMP_CWORD; i++ )); do
if [[ ${COMP_WORDS[i]} != -* ]]; then
local root_command=${COMP_WORDS[i]}
Expand All @@ -58,14 +54,20 @@ _systemd_run() {

[[ ${COMP_WORDS[i]} == "--user" ]] && mode=--user

[[ $i -lt $COMP_CWORD && " ${opts_with_values[@]} " =~ " ${COMP_WORDS[i]} " ]] && ((i++))
[[ $i -lt $COMP_CWORD && " ${opts_with_values[*]} " =~ " ${COMP_WORDS[i]} " ]] && ((i++))
done

case "$prev" in
--unit|--description|--on-active|--on-boot|--on-startup|--on-unit-active|--on-unit-inactive|--on-calendar)
--unit|--description|--on-active|--on-boot|--on-startup|--on-unit-active|--on-unit-inactive|--on-calendar|--background)
# argument required but no completions available
return
;;
--expand-environment)
local comps='yes no'

COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
;;
--slice)
local comps=$(__get_slice_units $mode)

Expand Down

0 comments on commit e579017

Please sign in to comment.