Docs: Generate balena auto-completion

Signed-off-by: Vipul Gupta (@vipulgupta2048) <vipulgupta2048@gmail.com>
This commit is contained in:
Vipul Gupta (@vipulgupta2048) 2023-11-10 01:45:29 +05:30
parent 2de9d526e5
commit 4cd8f4c16e
No known key found for this signature in database
GPG Key ID: D76FE376041D2649
3 changed files with 8 additions and 26 deletions

View File

@ -65,6 +65,12 @@ const commandHeadings: { [key: string]: string } = {
orgs: 'Organizations',
os: 'OS',
util: 'Utilities',
ssh: 'Network',
scan: 'Network',
tunnel: 'Network',
build: 'Deploy',
join: 'Platform',
leave: 'Platform',
};
// Fetch all available commands

View File

@ -8,14 +8,13 @@ _balena() {
local context state line curcontext="$curcontext"
# Valid top-level completions
main_commands=( api-key api-keys app auth block config deploy deploy device device devices env envs fleet fleet fleets internal key key keys local logs network notes orgs os platform preload push release release releases settings support tag tags util version )
main_commands=( api-key api-keys app auth block build config deploy device device devices env envs fleet fleet fleets internal join key key keys leave local logs notes orgs os preload push release release releases scan settings ssh support tag tags tunnel util version )
# Sub-completions
api_key_cmds=( generate revoke )
app_cmds=( create )
auth_cmds=( login logout whoami )
block_cmds=( create )
config_cmds=( generate inject read reconfigure write )
deploy_cmds=( build )
device_cmds=( deactivate identify init local-mode move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet )
devices_cmds=( supported )
env_cmds=( add rename rm )
@ -23,9 +22,7 @@ _balena() {
internal_cmds=( osinit )
key_cmds=( add rm )
local_cmds=( configure flash )
network_cmds=( scan ssh tunnel )
os_cmds=( build-config configure download initialize versions )
platform_cmds=( join leave )
release_cmds=( finalize invalidate validate )
tag_cmds=( rm set )
@ -61,9 +58,6 @@ _balena_sec_cmds() {
"config")
_describe -t config_cmds 'config_cmd' config_cmds "$@" && ret=0
;;
"deploy")
_describe -t deploy_cmds 'deploy_cmd' deploy_cmds "$@" && ret=0
;;
"device")
_describe -t device_cmds 'device_cmd' device_cmds "$@" && ret=0
;;
@ -85,15 +79,9 @@ _balena_sec_cmds() {
"local")
_describe -t local_cmds 'local_cmd' local_cmds "$@" && ret=0
;;
"network")
_describe -t network_cmds 'network_cmd' network_cmds "$@" && ret=0
;;
"os")
_describe -t os_cmds 'os_cmd' os_cmds "$@" && ret=0
;;
"platform")
_describe -t platform_cmds 'platform_cmd' platform_cmds "$@" && ret=0
;;
"release")
_describe -t release_cmds 'release_cmd' release_cmds "$@" && ret=0
;;

View File

@ -7,14 +7,13 @@ _balena_complete()
local cur prev
# Valid top-level completions
main_commands="api-key api-keys app auth block config deploy deploy device device devices env envs fleet fleet fleets internal key key keys local logs network notes orgs os platform preload push release release releases settings support tag tags util version"
main_commands="api-key api-keys app auth block build config deploy device device devices env envs fleet fleet fleets internal join key key keys leave local logs notes orgs os preload push release release releases scan settings ssh support tag tags tunnel util version"
# Sub-completions
api_key_cmds="generate revoke"
app_cmds="create"
auth_cmds="login logout whoami"
block_cmds="create"
config_cmds="generate inject read reconfigure write"
deploy_cmds="build"
device_cmds="deactivate identify init local-mode move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet"
devices_cmds="supported"
env_cmds="add rename rm"
@ -22,9 +21,7 @@ _balena_complete()
internal_cmds="osinit"
key_cmds="add rm"
local_cmds="configure flash"
network_cmds="scan ssh tunnel"
os_cmds="build-config configure download initialize versions"
platform_cmds="join leave"
release_cmds="finalize invalidate validate"
tag_cmds="rm set"
@ -55,9 +52,6 @@ _balena_complete()
config)
COMPREPLY=( $(compgen -W "$config_cmds" -- $cur) )
;;
deploy)
COMPREPLY=( $(compgen -W "$deploy_cmds" -- $cur) )
;;
device)
COMPREPLY=( $(compgen -W "$device_cmds" -- $cur) )
;;
@ -79,15 +73,9 @@ _balena_complete()
local)
COMPREPLY=( $(compgen -W "$local_cmds" -- $cur) )
;;
network)
COMPREPLY=( $(compgen -W "$network_cmds" -- $cur) )
;;
os)
COMPREPLY=( $(compgen -W "$os_cmds" -- $cur) )
;;
platform)
COMPREPLY=( $(compgen -W "$platform_cmds" -- $cur) )
;;
release)
COMPREPLY=( $(compgen -W "$release_cmds" -- $cur) )
;;