Files
moby/cmd
Sebastiaan van Stijn 3bb40af036 dockerd: enable shell-completion; add (hidden) completion subcommand
This required a minor hack to accommodate Cobra's logic (and a TODO was
added to see if we can improve that logic in upstream). Some changes also
had to be made to our "Usage" template, as our custom template did not
take into account subcommands and long descriptions for commands. We
should review these templates, as some additional features were added
in upstream Cobra that we currently may not be using.

With this patch:

instructions for the (hidden) completion subcommand:

    docker completion --help

    Usage:  docker completion COMMAND

    Generate the autocompletion script for docker for the specified shell.
    See each sub-command's help for details on how to use the generated script.

    Commands:
      bash        Generate the autocompletion script for bash
      fish        Generate the autocompletion script for fish
      powershell  Generate the autocompletion script for powershell
      zsh         Generate the autocompletion script for zsh

    Run 'docker completion COMMAND --help' for more information on a command.

and instructions for installing:

    dockerd completion bash --help

    Usage:	dockerd completion bash

    Generate the autocompletion script for the bash shell.

    This script depends on the 'bash-completion' package.
    If it is not installed already, you can install it via your OS's package manager.

    To load completions in your current shell session:

        source <(dockerd completion bash)

    To load completions for every new session, execute once:

    #### Linux:

        dockerd completion bash > /etc/bash_completion.d/dockerd

    #### macOS:

        dockerd completion bash > $(brew --prefix)/etc/bash_completion.d/dockerd

    You will need to start a new shell for this setup to take effect.

    Options:
          --help              Print usage
          --no-descriptions   disable completion descriptions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 17:12:26 +01:00
..