SUSE/saptune

View on GitHub
ospackage/usr/share/bash-completion/completions/build/saptune-completion.yaml

Summary

Maintainability
Test Coverage
# This is the input configuration for 'completely' (https://github.com/DannyBen/completely)
# to generate the bash completion script.
#
# v2.3
#
# Changelog:    29.09.2022  v2.0  - first release for saptune 3.1
#               21.11.2022  v2.1  - Replace --output with --format in syntax description
#                                 - Add `saptune solution change [--force]`
#               16.01.2023  v2.2  - Bugfix: custom notes have bee displayed with `.conf` suffix
#                                 - Bugfix: `saptune note|solution create` don't have a completion anymore
#                                 - Bugfix: `saptune note|solution delete|rename' now only offers custom notes/solutions
#               13.06.2023  v2.3  - Bugfix: `saptune staging` commands do not remove the required `.sol` extension anymore
#                                 - Bugfix: some `saptune note verify` commands did not remove the `.conf` suffix
#                                 - Bugfix: `saptune note|solution revert` now only completes applied notes/solutions.
#                                 - Bugfix: `saptune solution edit` now only completes custom solutions
#
# Syntax:       saptune [--format FORMAT] help
#               saptune [--format FORMAT] version  
#               saptune [--format FORMAT] status [--non-compliance-check] 
#               saptune [--format FORMAT] daemon ( start | stop | status [--non-compliance-check] )
#               saptune [--format FORMAT] service ( start | stop | restart | takeover | enable | disable | enablestart | disablestop | status [--non-compliance-check] )
#               saptune [--format FORMAT] note ( list | revertall | enabled | applied )
#               saptune [--format FORMAT] note ( apply | simulate | customise | create | edit | revert | show | delete ) NOTEID
#               saptune [--format FORMAT] note verify [--colorscheme SCHEME] [--show-non-compliant] [NOTEID]
#               saptune [--format FORMAT] note rename NOTEID NEWNOTEID
#               saptune [--format FORMAT] solution ( list | verify | enabled | applied )
#               saptune [--format FORMAT] solution ( apply | simulate | customise | create | edit | revert | show | delete | change [--force] ) SOLUTIONNAME
#               saptune [--format FORMAT] solution verify [--colorscheme SCHEME] [--show-non-compliant] [SOLUTIONID]
#               saptune [--format FORMAT] solution rename SOLUTIONNAME NEWSSOLUTIONNAME
#               saptune [--format FORMAT] staging ( status | enable | disable | is-enabled | list )
#               saptune [--format FORMAT] staging ( analysis | diff ) [ ( NOTEID | SOLUTIONNAME.sol )... | all ]
#               saptune [--format FORMAT] staging release [--force|--dry-run] [ ( NOTEID | SOLUTIONNAME.sol )... | all ]
#               saptune [--format FORMAT] revert all
#               saptune [--format FORMAT] lock remove
#               saptune [--format FORMAT] check
#
#
# Caveats:      - It is not possible to use the '=' sign in options. Completion will stop at the '=' sign. The reason for this
#                 is that the character is listed in `COMP_WORDBREAKS`. Removing it can break other completions, so this is not an option.
#                 (Tricks to use a different character as marker and overwriting the space with an injected backspace to add the `=` later
#                  doesn't work. The completions prints the code instead. Anyways the added `=` would break the completion during corrections.)
#                 There might a way to implement this (https://www.gnu.org/software/gnuastro/manual/html_node/Bash-TAB-completion-tutorial.html),
#                 but trying it out and rewriting the code would cost to much time for now.
#
#               - It is not feasible to write this YAML file to fully support the option ('--format FORMAT') which comes immediately 
#                 after 'saptune'. Each combination must be listed in this file, which would double the current entries. 
#                 Therefore all more complex completion lack these variations, because a snippet gets injected into the compiled completion, 
#                 which removes `--format json` it from the COMP_WORDS, so it does not needed to take into account.
#
#               - The completely resolved command needs to have a dummy entry: '$()' (empty command) to stop further
#                 processing.
#
#
# ToDo :        - Implementing support for the `=` sign.



# --- First level ---
saptune:
  - --format
  - help
  - version  
  - status
  - daemon
  - service
  - note
  - solution
  - staging
  - revert
  - lock
  - check

# --- start: support for global format option ---
#
# THIS BLOCK PREVENTS A WORKABLE SOLUTION WITH THE REST
# OF THE DEFINITION UNLESS THE FOLLOWING BLOCK GETS ADDED
# TO THE RESULTING SCRIPT AS FIRST LINES OF THE FUNCTION
# '_saptune_completions()':
#
#  if [[ "${COMP_WORDS[*]}" =~ ^saptune\ --format\ json ]] ; then
#        unset COMP_WORDS[1]  # remove '--format'
#        unset COMP_WORDS[2]  # remove 'json'
#        COMP_WORDS=( ${COMP_WORDS[@]} )
#        ((COMP_CWORD-=2))
#  fi
#
# THIS IS CURRENTLY THE ONLY WAY TO SUPPORT THE FORMAT
# OPTION WITHOUT LETTING THE AMOUNT OF DEFINITIONS IN THIS
# FILE EXPLODE.

saptune --format:
  - json

saptune --format *:
  - help
  - version  
  - status
  - daemon
  - service
  - note
  - solution
  - staging
  - revert
  - lock
  - check

# --- end: support for global format option ---

# --- saptune help ---
saptune help:
  - $()


# --- saptune version ---
saptune version:
  - $()


# --- saptune status ---
saptune status:
  - --non-compliance-check
  - $()

saptune status --non-compliance-check:
  - $()

# --- saptune daemon ---
saptune daemon:
  - start
  - stop
  - status

saptune daemon start: &stop
  - $()

saptune daemon stop: *stop

saptune daemon status:
  - --non-compliance-check
  - $()

saptune daemon status --non-compliance-check: *stop


# --- saptune service ---
saptune service:
  - start
  - stop
  - restart 
  - takeover 
  - enable 
  - disable 
  - enablestart 
  - disablestop 
  - status 

saptune service start: &stop
  - $()

saptune service stop: *stop

saptune service restart: *stop

saptune service takeover: *stop

saptune service enable: *stop

saptune service disable: *stop

saptune service enablestart: *stop

saptune service disablestop: *stop

saptune service status:
  - --non-compliance-check
  - $()

saptune service status*--non-compliance-check: *stop


# --- saptune note ---
saptune note:
  - list
  - revertall
  - enabled
  - applied
  - apply
  - simulate
  - customise
  - create
  - edit
  - revert
  - show
  - delete
  - verify
  - rename

saptune note list: &stop
  - $()

saptune note revertall: *stop

saptune note enabled: *stop

saptune note applied: *stop

saptune note apply: &list-all-notes
  - $(ls /var/lib/saptune/working/notes/)
  - $(cd /etc/saptune/extra/; for f in *.conf ; do echo ${f%.conf} ; done)

saptune note apply *: *stop

saptune note simulate: *list-all-notes

saptune note simulate *: *stop

saptune note customise: *list-all-notes

saptune note customise *: *stop

saptune note create: *stop

saptune note create *: *stop

saptune note edit:
  - $(cd /etc/saptune/extra/; for f in *.conf ; do echo ${f%.conf} ; done)

saptune note edit *: *stop

saptune note revert:
  - $(saptune note applied)

saptune note revert *: *stop

saptune note show: *list-all-notes

saptune note show *: *stop

saptune note delete:
  - $(cd /etc/saptune/extra/; for f in *.conf ; do echo ${f%.conf} ; done)

saptune note delete *: *stop

saptune note verify:
  - --colorscheme
  - --show-non-compliant
  - $(ls /var/lib/saptune/working/notes/)
  - $(cd /etc/saptune/extra/; for f in *.conf ; do echo ${f%.conf} ; done)

saptune note verify *: *stop
  
saptune note verify --show-non-compliant:
  - --colorscheme
  - $(ls /var/lib/saptune/working/notes/)
  - $(cd /etc/saptune/extra/; for f in *.conf ; do echo ${f%.conf} ; done)

saptune note verify --show-non-compliant *: *stop

saptune note verify --show-non-compliant --colorscheme: &color-schemes
  - full-green-zebra
  - full-blue-zebra
  - cmpl-green-zebra
  - cmpl-blue-zebra
  - full-red-noncmpl
  - full-yellow-noncmpl
  - red-noncmpl
  - yellow-noncmpl

saptune note verify --show-non-compliant --colorscheme *: *list-all-notes

saptune note verify --show-non-compliant --colorscheme * *: *stop

saptune note verify --colorscheme: *color-schemes

saptune note verify --colorscheme *:
  - --show-non-compliant
  - $(ls /var/lib/saptune/working/notes/)
  - $(cd /etc/saptune/extra/; for f in *.conf ; do echo ${f%.conf} ; done)

saptune note verify --colorscheme * *: *stop

saptune note verify --colorscheme * --show-non-compliant: *list-all-notes

saptune note verify --colorscheme * --show-non-compliant *: *stop

saptune note rename:
  - $(cd /etc/saptune/extra/; for f in *.conf ; do echo ${f%.conf} ; done)

saptune note rename *: *stop 


# --- saptune solution ---
saptune solution:
  - list
  - enabled
  - applied
  - apply
  - simulate
  - customise
  - create
  - edit
  - revert
  - show
  - delete
  - change
  - verify
  - rename

saptune solution list: &stop
  - $()

saptune solution enabled: *stop

saptune solution applied: *stop

saptune solution apply: &list-all-solutions
  - $(cd /var/lib/saptune/working/sols/ ; for f in *.sol ; do echo ${f%.sol} ; done)
  - $(cd /etc/saptune/extra/; for f in *.sol ; do echo ${f%.sol} ; done)

saptune solution apply *: *stop

saptune solution simulate: *list-all-solutions

saptune solution simulate *: *stop

saptune solution customise: *list-all-solutions

saptune solution customise *: *stop

saptune solution create: *stop

saptune solution create *: *stop

saptune solution edit:
  - $(cd /etc/saptune/extra/; for f in *.sol ; do echo ${f%.sol} ; done)

saptune solution edit *: *stop

saptune solution revert: 
  - $(saptune solution applied | sed 's/(partial)//g')

saptune solution revert *: *stop

saptune solution show: *list-all-solutions

saptune solution show *: *stop

saptune solution delete:
  - $(cd /etc/saptune/extra/; for f in *.sol ; do echo ${f%.sol} ; done)

saptune solution delete *: *stop

saptune solution change: 
  - --force
  - $(find /var/lib/saptune/working/sols/ /etc/saptune/extra/ -name '*.sol' -printf '%P ' | sed 's/\.sol//g')

saptune solution change --force: *list-all-solutions

saptune solution change *: *stop

saptune solution change --force *: *stop 

saptune solution verify: 
  - --colorscheme
  - --show-non-compliant
  - $(find /var/lib/saptune/working/sols/ /etc/saptune/extra/ -name '*.sol' -printf '%P ' | sed 's/\.sol//g')

saptune solution verify *: *stop
  
saptune solution verify --show-non-compliant:
  - --colorscheme
  - $(find /var/lib/saptune/working/sols/ /etc/saptune/extra/ -name '*.sol' -printf '%P ' | sed 's/\.sol//g')

saptune solution verify --show-non-compliant *: *stop

saptune solution verify --show-non-compliant --colorscheme: &color-schemes
  - full-green-zebra
  - full-blue-zebra
  - cmpl-green-zebra
  - cmpl-blue-zebra
  - full-red-noncmpl
  - full-yellow-noncmpl
  - red-noncmpl
  - yellow-noncmpl

saptune solution verify --show-non-compliant --colorscheme *: *list-all-solutions

saptune solution verify --show-non-compliant --colorscheme * *: *stop

saptune solution verify --colorscheme: *color-schemes

saptune solution verify --colorscheme *:
  - --show-non-compliant
  - $(find /var/lib/saptune/working/sols/ /etc/saptune/extra/ -name '*.sol' -printf '%P ' | sed 's/\.sol//g')

saptune solution verify --colorscheme * *: *stop

saptune solution verify --colorscheme * --show-non-compliant: *list-all-solutions

saptune solution verify --colorscheme * --show-non-compliant *: *stop

saptune solution rename:
  - $(cd /etc/saptune/extra/; for f in *.sol ; do echo ${f%.sol} ; done)

saptune solution rename *: *stop 


# --- saptune staging ---
saptune staging:
  - status
  - enable
  - disable
  - is-enabled
  - list
  - diff
  - analysis
  - release

saptune staging status:
  - $()

saptune staging enable:
  - $()

saptune staging disable:
  - $()

saptune staging is-enabled:
  - $()

saptune staging list:
  - $()


saptune staging diff:
  - $(find /var/lib/saptune/staging/latest/ -printf '%P ')
  - all
  
saptune staging diff *:
  - $(find /var/lib/saptune/staging/latest/ -printf '%P ')

saptune staging diff all:
  - $()

saptune staging analysis:
  - $(find /var/lib/saptune/staging/latest/ -printf '%P ')
  - all
  
saptune staging analysis *:
  - $(find /var/lib/saptune/staging/latest/ -printf '%P ')

saptune staging analysis all:
  - $()

saptune staging release:
  - --force
  - --dry-run
  - $(find /var/lib/saptune/staging/latest/ -printf '%P ')
  - all

saptune staging release --force:
  - $(find /var/lib/saptune/staging/latest/ -printf '%P ')
  - all

saptune staging release --force all:
  - $()

saptune staging release --dry-run:
  - $(find /var/lib/saptune/staging/latest/ -printf '%P ')
  - all

saptune staging release --dry-run all:
  - $()

saptune staging release *:
  - $(find /var/lib/saptune/staging/latest/ -printf '%P ')

saptune staging release all:
  - $()


# --- saptune revert ---
saptune revert:
  - all 

saptune revert all:
  - $()


# --- saptune lock ---
saptune lock:
  - remove

saptune lock remove: 
  - $()


# --- saptune check ---
saptune check: 
  - $()