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.
#
# v3.0
#
# 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
#               07.11.2024  v3.0  - Bugfix: Note and Solution lists for revert contained warning and notice messages 
#                                 - Added `saptune note verify applied` and `saptune verify applied`
#                                 - Added `--fun` and `--force-color`` and therefore rewrote injected script. 
#                                 - Added `saptune configure`
#                                 - Added `saptune note refresh` and `saptune refresh applied`
#
# Syntax:       saptune [--format FORMAT] [--fun] [--force-color] help
#               saptune [--format FORMAT] [--fun] [--force-color] version  
#               saptune [--format FORMAT] [--fun] [--force-color] status [--non-compliance-check] 
#               saptune [--format FORMAT] [--fun] [--force-color] daemon ( start | stop | status [--non-compliance-check] )
#               saptune [--format FORMAT] [--fun] [--force-color] service ( start | stop | restart | takeover | enable | disable | enablestart | disablestop | status [--non-compliance-check] )
#               saptune [--format FORMAT] [--fun] [--force-color] note ( list | revertall | enabled | applied | verify )
#               saptune [--format FORMAT] [--fun] [--force-color] note ( apply | simulate | customise | create | edit | revert | show | delete ) NOTEID
#               saptune [--format FORMAT] [--fun] [--force-color] note verify [--colorscheme SCHEME] [--show-non-compliant] [NOTEID|applied]
#               saptune [--format FORMAT] [--fun] [--force-color] note rename NOTEID NEWNOTEID
#               saptune [--format FORMAT] [--fun] [--force-color] solution ( list | verify | enabled | applied )
#               saptune [--format FORMAT] [--fun] [--force-color] solution ( apply | simulate | customise | create | edit | revert | show | delete | change [--force] ) SOLUTIONNAME
#               saptune [--format FORMAT] [--fun] [--force-color] solution verify [--colorscheme SCHEME] [--show-non-compliant] [SOLUTIONID]
#               saptune [--format FORMAT] [--fun] [--force-color] solution rename SOLUTIONNAME NEWSSOLUTIONNAME
#               saptune [--format FORMAT] [--fun] [--force-color] staging ( status | enable | disable | is-enabled | list )
#               saptune [--format FORMAT] [--fun] [--force-color] staging ( analysis | diff ) [ ( NOTEID | SOLUTIONNAME.sol )... | all ]
#               saptune [--format FORMAT] [--fun] [--force-color] staging release [--force|--dry-run] [ ( NOTEID | SOLUTIONNAME.sol )... | all ]
#               saptune [--format FORMAT] [--fun] [--force-color] configure OPTION VALUE
#               saptune [--format FORMAT] [--fun] [--force-color] configure ( reset | show )
#               saptune [--format FORMAT] [--fun] [--force-color] refresh NOTEID|applied
#               saptune [--format FORMAT] [--fun] [--force-color] revert all
#               saptune [--format FORMAT] [--fun] [--force-color] lock remove
#               saptune [--format FORMAT] [--fun] [--force-color] check
#               saptune [--format FORMAT] [--fun] [--force-color] verify applied
#               saptune [--format FORMAT] [--fun] [--force-color] refresh applied
#
#
#
# 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.
#                 There seems to be added support in `completely` v0.6.3. Not investigated yet, but we won't introduce a `=` anymore. It would
#                 break the introduced CLI interface.
#
#               - It is not feasible to write this YAML file to fully support global options which come immediately after 'saptune'. 
#                 Each combination must be listed in this file, which would double the entries for each global option. 
#                 Therefore all saptune command completions lack these variations, because a snippet gets injected into the compiled 
#                 completion script, which removes global options from the COMP_WORDS, so they don't need to take into account.
#
#               - The completely resolved command needs to have a dummy entry: '$()' (empty command) to stop further
#                 processing.
           

# --- First level ---
saptune:
  - --format
  - --force-color
  - --fun
  - help
  - version  
  - status
  - daemon
  - service
  - note
  - solution
  - staging
  - revert
  - lock
  - check
  - verify
  - configure
  - refresh

# --- start: support for global options ---
#
# THIS BLOCK GUARANTEES A WORKABLE SOLUTION WITH THE REST OF
# THE DEFINITION AND MUST BE ADDED TO THE RESULTING SCRIPT 
# AS FIRST LINES OF THE FUNCTION '_saptune_completions()':
#
# if [[ "${COMP_WORDS[*]}" =~ (--format\ json|--force-color|--fun) ]] ; then
#   word_count=${#COMP_WORDS[@]}
#   for (( index=0; index<${word_count}; index++ )) ; do
#     case "${COMP_WORDS[index]}" in
#       --format)
#           if [ "${COMP_WORDS[index+1]}" == json ] ; then
#             unset COMP_WORDS[index]    # remove '--format'
#             unset COMP_WORDS[index+1]  # remove 'json'
#           fi
#           ;;
#       --force-color)
#           unset COMP_WORDS[index]    # remove '--force-color'
#           ;;
#       --fun)
#           unset COMP_WORDS[index]    # remove '--fun'
#           ;;
#     esac          
#   done
#   COMP_CWORD=$(( ${#COMP_WORDS[@]}-1 ))
#   COMP_WORDS=( ${COMP_WORDS[@]} )
# fi
#
# THIS IS CURRENTLY THE ONLY WAY TO SUPPORT THE GLOBAL OPTIONS
# WITHOUT LETTING THE AMOUNT OF DEFINITIONS IN THIS FILE EXPLODE.

saptune --format:
  - json

saptune --format *:
  - --force-color
  - --fun
  - help
  - version  
  - status
  - daemon
  - service
  - note
  - solution
  - staging
  - revert
  - lock
  - check
  - verify
  - configure
  - refresh

# --- 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
  - refresh

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 2> /dev/null | egrep -v -e '^[[:space:]]*$' -e '^(WARNING|NOTICE|INFO|DEBUG)' )

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)
  - applied

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)
  - applied

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 *:
  - $(ls /var/lib/saptune/working/notes/)
  - $(cd /etc/saptune/extra/; for f in *.conf ; do echo ${f%.conf} ; done)
  - applied

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)
  - applied

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 note refresh:
  - $(ls /var/lib/saptune/working/notes/)
  - $(cd /etc/saptune/extra/; for f in *.conf ; do echo ${f%.conf} ; done)
  - applied  

saptune note refresh *: *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 2> /dev/null | egrep -v -e '^[[:space:]]*$' -e '^(WARNING|NOTICE|INFO|DEBUG)' | 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: &stop
  - $()

saptune staging enable: *stop

saptune staging disable: *stop

saptune staging is-enabled: *stop

saptune staging list: *stop

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: *stop

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: *stop

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: *stop

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

saptune staging release --dry-run all: *stop

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

saptune staging release all:  *stop


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

saptune revert all:
  - $()


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

saptune lock remove: 
  - $()


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


# --- saptune verify ---
saptune verify: 
  - applied

saptune verify applied: 
  - $()


# --- saptune configure ---
saptune configure: 
  - reset
  - show
  - COLOR_SCHEME
  - SKIP_SYSCTL_FILES
  - IGNORE_RELOAD
  - DEBUG 
  - trento-agent-saptune-discovery-period

saptune configure COLOR_SCHEME: *color-schemes

saptune configure COLOR_SCHEME *: &stop 
  - $() 

saptune configure SKIP_SYSCTL_FILES: *stop    # no file suggestions, because the list must be comma separated. 

saptune configure SKIP_SYSCTL_FILES *: *stop 

saptune configure IGNORE_RELOAD:
  - "yes"
  - "no"

saptune configure IGNORE_RELOAD *:  *stop

saptune configure DEBUG:
  - "on"
  - "off" 

saptune configure DEBUG *:  *stop

saptune configure trento-agent-saptune-discovery-period:
  - "300"
  - "600"
  - "900"
  - "1800"
  - "3600"

saptune configure trento-agent-saptune-discovery-period *: *stop

saptune configure reset: *stop
  
saptune configure show: *stop 


# --- saptune refresh ---
saptune refresh: 
  - applied

saptune refresh applied: 
  - $()