Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 101 additions & 4 deletions completions/zsh/_crio
Original file line number Diff line number Diff line change
@@ -1,13 +1,110 @@
_cli_zsh_autocomplete() {

local -a cmds
cmds=('complete:Generate bash, fish or zsh completions.' 'completion:Generate bash, fish or zsh completions.' 'man:Generate the man page documentation.' 'markdown:Generate the markdown documentation.' 'md:Generate the markdown documentation.' 'config:Outputs a commented version of the configuration file that could be used
by CRI-O. This allows you to save you current configuration setup and then load
it later with **--config**. Global options will modify the output.' 'version:display detailed version information' 'wipe:wipe CRI-O's container and image storage' 'help:Shows a list of commands or help for one command' 'h:Shows a list of commands or help for one command')
cmds=('complete:Generate bash, fish or zsh completions.'
'completion:Generate bash, fish or zsh completions.'
'man:Generate the man page documentation.'
'markdown:Generate the markdown documentation.'
'md:Generate the markdown documentation.'
'config:Outputs a commented version of the configuration file that could be used by CRI-O. This allows you to save you current configuration setup and then load it later with **--config**. Global options will modify the output.'
'version:display detailed version information'
'wipe:wipe CRI-O'"'"'s container and image storage'
'help:Shows a list of commands or help for one command'
'h:Shows a list of commands or help for one command')
_describe 'commands' cmds

local -a opts
opts=('--absent-mount-sources-to-reject' '--additional-devices' '--address' '--apparmor-profile' '--big-files-temporary-dir' '--bind-mount-prefix' '--blockio-config-file' '--cgroup-manager' '--clean-shutdown-file' '--cni-config-dir' '--cni-default-network' '--cni-plugin-dir' '--config' '--config-dir' '--conmon' '--conmon-cgroup' '--conmon-env' '--container-attach-socket-dir' '--container-exits-dir' '--ctr-stop-timeout' '--decryption-keys-path' '--default-capabilities' '--default-env' '--default-mounts-file' '--default-runtime' '--default-sysctls' '--default-transport' '--default-ulimits' '--device-ownership-from-security-context' '--drop-infra-ctr' '--enable-metrics' '--enable-profile-unix-socket' '--gid-mappings' '--global-auth-file' '--grpc-max-recv-msg-size' '--grpc-max-send-msg-size' '--hooks-dir' '--image-volumes' '--infra-ctr-cpuset' '--insecure-registry' '--internal-wipe' '--irqbalance-config-file' '--listen' '--log' '--log-dir' '--log-filter' '--log-format' '--log-journald' '--log-level' '--log-size-max' '--metrics-cert' '--metrics-collectors' '--metrics-key' '--metrics-port' '--metrics-socket' '--namespaces-dir' '--no-pivot' '--pause-command' '--pause-image' '--pause-image-auth-file' '--pids-limit' '--pinns-path' '--profile' '--profile-port' '--rdt-config-file' '--read-only' '--registries-conf' '--registries-conf-dir' '--registry' '--root' '--runroot' '--runtimes' '--seccomp-profile' '--seccomp-use-default-when-empty' '--selinux' '--separate-pull-cgroup' '--signature-policy' '--storage-driver' '--storage-opt' '--stream-address' '--stream-enable-tls' '--stream-idle-timeout' '--stream-port' '--stream-tls-ca' '--stream-tls-cert' '--stream-tls-key' '--uid-mappings' '--version-file' '--version-file-persist' '--help' '--version')
opts=('--absent-mount-sources-to-reject'
'--additional-devices'
'--address'
'--apparmor-profile'
'--big-files-temporary-dir'
'--bind-mount-prefix'
'--blockio-config-file'
'--cgroup-manager'
'--clean-shutdown-file'
'--cni-config-dir'
'--cni-default-network'
'--cni-plugin-dir'
'--config'
'--config-dir'
'--conmon'
'--conmon-cgroup'
'--conmon-env'
'--container-attach-socket-dir'
'--container-exits-dir'
'--ctr-stop-timeout'
'--decryption-keys-path'
'--default-capabilities'
'--default-env'
'--default-mounts-file'
'--default-runtime'
'--default-sysctls'
'--default-transport'
'--default-ulimits'
'--device-ownership-from-security-context'
'--drop-infra-ctr'
'--enable-metrics'
'--enable-profile-unix-socket'
'--gid-mappings'
'--global-auth-file'
'--grpc-max-recv-msg-size'
'--grpc-max-send-msg-size'
'--hooks-dir'
'--image-volumes'
'--infra-ctr-cpuset'
'--insecure-registry'
'--internal-wipe'
'--irqbalance-config-file'
'--listen'
'--log'
'--log-dir'
'--log-filter'
'--log-format'
'--log-journald'
'--log-level'
'--log-size-max'
'--metrics-cert'
'--metrics-collectors'
'--metrics-key'
'--metrics-port'
'--metrics-socket'
'--namespaces-dir'
'--no-pivot'
'--pause-command'
'--pause-image'
'--pause-image-auth-file'
'--pids-limit'
'--pinns-path'
'--profile'
'--profile-port'
'--rdt-config-file'
'--read-only'
'--registries-conf'
'--registries-conf-dir'
'--registry'
'--root'
'--runroot'
'--runtimes'
'--seccomp-profile'
'--seccomp-use-default-when-empty'
'--selinux'
'--separate-pull-cgroup'
'--signature-policy'
'--storage-driver'
'--storage-opt'
'--stream-address'
'--stream-enable-tls'
'--stream-idle-timeout'
'--stream-port'
'--stream-tls-ca'
'--stream-tls-cert'
'--stream-tls-key'
'--uid-mappings'
'--version-file'
'--version-file-persist'
'--help'
'--version')
_describe 'global options' opts

return
Expand Down
20 changes: 18 additions & 2 deletions completions/zsh/_crio-status
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
_cli_zsh_autocomplete() {

local -a cmds
cmds=('complete:Generate bash, fish or zsh completions.' 'completion:Generate bash, fish or zsh completions.' 'man:Generate the man page documentation.' 'markdown:Generate the markdown documentation.' 'md:Generate the markdown documentation.' 'config:Show the configuration of CRI-O as TOML string.' 'c:Show the configuration of CRI-O as TOML string.' 'containers:Display detailed information about the provided container ID.' 'container:Display detailed information about the provided container ID.' 'cs:Display detailed information about the provided container ID.' 's:Display detailed information about the provided container ID.' 'info:Retrieve generic information about CRI-O, like the cgroup and storage driver.' 'i:Retrieve generic information about CRI-O, like the cgroup and storage driver.' 'help:Shows a list of commands or help for one command' 'h:Shows a list of commands or help for one command')
cmds=('complete:Generate bash, fish or zsh completions.'
'completion:Generate bash, fish or zsh completions.'
'man:Generate the man page documentation.'
'markdown:Generate the markdown documentation.'
'md:Generate the markdown documentation.'
'config:Show the configuration of CRI-O as TOML string.'
'c:Show the configuration of CRI-O as TOML string.'
'containers:Display detailed information about the provided container ID.'
'container:Display detailed information about the provided container ID.'
'cs:Display detailed information about the provided container ID.'
's:Display detailed information about the provided container ID.'
'info:Retrieve generic information about CRI-O, like the cgroup and storage driver.'
'i:Retrieve generic information about CRI-O, like the cgroup and storage driver.'
'help:Shows a list of commands or help for one command'
'h:Shows a list of commands or help for one command')
_describe 'commands' cmds

local -a opts
opts=('--socket' '--help' '--version')
opts=('--socket'
'--help'
'--version')
_describe 'global options' opts

return
Expand Down
8 changes: 5 additions & 3 deletions internal/criocli/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ func zshCompletion(c *cli.Context) error {
continue
}
for _, name := range command.Names() {
subcommands = append(subcommands, name+":"+command.Usage)
escapedUsage := strings.ReplaceAll(command.Usage, "'", "'\"'\"'")
escapedUsage = strings.ReplaceAll(escapedUsage, "\n", " ")
subcommands = append(subcommands, name+":"+escapedUsage)
}
}

Expand All @@ -106,8 +108,8 @@ func zshCompletion(c *cli.Context) error {

fmt.Fprintln(c.App.Writer,
fmt.Sprintf(zshCompletionTemplate,
strings.Join(subcommands, "' '"),
strings.Join(opts, "' '"),
strings.Join(subcommands, "'\n '"),
strings.Join(opts, "'\n '"),
c.App.Name))
return nil
}
Expand Down