2016-09-08 13:11:39 -04:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2016-09-12 11:37:00 -04:00
|
|
|
"os"
|
|
|
|
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli/command"
|
2018-08-17 05:51:04 -04:00
|
|
|
"github.com/docker/cli/cli/command/builder"
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli/command/checkpoint"
|
2017-05-08 13:36:04 -04:00
|
|
|
"github.com/docker/cli/cli/command/config"
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli/command/container"
|
2018-11-09 09:10:41 -05:00
|
|
|
"github.com/docker/cli/cli/command/context"
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli/command/image"
|
2017-06-15 14:41:54 -04:00
|
|
|
"github.com/docker/cli/cli/command/manifest"
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli/command/network"
|
|
|
|
"github.com/docker/cli/cli/command/node"
|
|
|
|
"github.com/docker/cli/cli/command/plugin"
|
|
|
|
"github.com/docker/cli/cli/command/registry"
|
|
|
|
"github.com/docker/cli/cli/command/secret"
|
|
|
|
"github.com/docker/cli/cli/command/service"
|
|
|
|
"github.com/docker/cli/cli/command/stack"
|
|
|
|
"github.com/docker/cli/cli/command/swarm"
|
|
|
|
"github.com/docker/cli/cli/command/system"
|
2017-08-24 18:43:55 -04:00
|
|
|
"github.com/docker/cli/cli/command/trust"
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli/command/volume"
|
2016-09-08 13:11:39 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2016-09-08 14:54:01 -04:00
|
|
|
// AddCommands adds all the commands from cli/command to the root command
|
2018-06-14 10:26:47 -04:00
|
|
|
func AddCommands(cmd *cobra.Command, dockerCli command.Cli) {
|
2016-09-08 13:11:39 -04:00
|
|
|
cmd.AddCommand(
|
2022-03-29 17:36:48 -04:00
|
|
|
// commonly used shorthands
|
2016-09-08 13:11:39 -04:00
|
|
|
container.NewRunCommand(dockerCli),
|
2022-03-29 17:47:45 -04:00
|
|
|
container.NewExecCommand(dockerCli),
|
|
|
|
container.NewPsCommand(dockerCli),
|
2016-09-08 13:11:39 -04:00
|
|
|
image.NewBuildCommand(dockerCli),
|
2022-03-29 17:47:45 -04:00
|
|
|
image.NewPullCommand(dockerCli),
|
|
|
|
image.NewPushCommand(dockerCli),
|
|
|
|
image.NewImagesCommand(dockerCli),
|
2022-03-29 17:36:48 -04:00
|
|
|
registry.NewLoginCommand(dockerCli),
|
|
|
|
registry.NewLogoutCommand(dockerCli),
|
|
|
|
registry.NewSearchCommand(dockerCli),
|
|
|
|
system.NewVersionCommand(dockerCli),
|
2022-03-29 17:47:45 -04:00
|
|
|
system.NewInfoCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
2022-03-29 17:36:48 -04:00
|
|
|
// management commands
|
2018-08-17 05:51:04 -04:00
|
|
|
builder.NewBuilderCommand(dockerCli),
|
2022-03-29 17:36:48 -04:00
|
|
|
checkpoint.NewCheckpointCommand(dockerCli),
|
|
|
|
container.NewContainerCommand(dockerCli),
|
|
|
|
context.NewContextCommand(dockerCli),
|
|
|
|
image.NewImageCommand(dockerCli),
|
2017-06-15 14:41:54 -04:00
|
|
|
manifest.NewManifestCommand(dockerCli),
|
2016-09-08 13:11:39 -04:00
|
|
|
network.NewNetworkCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
plugin.NewPluginCommand(dockerCli),
|
2022-03-29 17:36:48 -04:00
|
|
|
system.NewSystemCommand(dockerCli),
|
|
|
|
trust.NewTrustCommand(dockerCli),
|
|
|
|
volume.NewVolumeCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
2022-03-29 17:36:48 -04:00
|
|
|
// orchestration (swarm) commands
|
|
|
|
config.NewConfigCommand(dockerCli),
|
|
|
|
node.NewNodeCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
secret.NewSecretCommand(dockerCli),
|
|
|
|
service.NewServiceCommand(dockerCli),
|
|
|
|
stack.NewStackCommand(dockerCli),
|
|
|
|
swarm.NewSwarmCommand(dockerCli),
|
|
|
|
|
|
|
|
// legacy commands may be hidden
|
2016-06-23 13:03:40 -04:00
|
|
|
hide(container.NewAttachCommand(dockerCli)),
|
|
|
|
hide(container.NewCommitCommand(dockerCli)),
|
|
|
|
hide(container.NewCopyCommand(dockerCli)),
|
|
|
|
hide(container.NewCreateCommand(dockerCli)),
|
|
|
|
hide(container.NewDiffCommand(dockerCli)),
|
|
|
|
hide(container.NewExportCommand(dockerCli)),
|
|
|
|
hide(container.NewKillCommand(dockerCli)),
|
|
|
|
hide(container.NewLogsCommand(dockerCli)),
|
|
|
|
hide(container.NewPauseCommand(dockerCli)),
|
|
|
|
hide(container.NewPortCommand(dockerCli)),
|
|
|
|
hide(container.NewRenameCommand(dockerCli)),
|
|
|
|
hide(container.NewRestartCommand(dockerCli)),
|
|
|
|
hide(container.NewRmCommand(dockerCli)),
|
|
|
|
hide(container.NewStartCommand(dockerCli)),
|
|
|
|
hide(container.NewStatsCommand(dockerCli)),
|
|
|
|
hide(container.NewStopCommand(dockerCli)),
|
|
|
|
hide(container.NewTopCommand(dockerCli)),
|
|
|
|
hide(container.NewUnpauseCommand(dockerCli)),
|
|
|
|
hide(container.NewUpdateCommand(dockerCli)),
|
|
|
|
hide(container.NewWaitCommand(dockerCli)),
|
|
|
|
hide(image.NewHistoryCommand(dockerCli)),
|
|
|
|
hide(image.NewImportCommand(dockerCli)),
|
|
|
|
hide(image.NewLoadCommand(dockerCli)),
|
|
|
|
hide(image.NewRemoveCommand(dockerCli)),
|
|
|
|
hide(image.NewSaveCommand(dockerCli)),
|
|
|
|
hide(image.NewTagCommand(dockerCli)),
|
2022-03-29 17:36:48 -04:00
|
|
|
hide(system.NewEventsCommand(dockerCli)),
|
|
|
|
hide(system.NewInspectCommand(dockerCli)),
|
2016-09-08 13:11:39 -04:00
|
|
|
)
|
|
|
|
}
|
2016-06-23 13:03:40 -04:00
|
|
|
|
|
|
|
func hide(cmd *cobra.Command) *cobra.Command {
|
2016-12-01 11:08:24 -05:00
|
|
|
// If the environment variable with name "DOCKER_HIDE_LEGACY_COMMANDS" is not empty,
|
|
|
|
// these legacy commands (such as `docker ps`, `docker exec`, etc)
|
|
|
|
// will not be shown in output console.
|
2016-09-12 11:37:00 -04:00
|
|
|
if os.Getenv("DOCKER_HIDE_LEGACY_COMMANDS") == "" {
|
|
|
|
return cmd
|
|
|
|
}
|
2016-06-23 13:03:40 -04:00
|
|
|
cmdCopy := *cmd
|
|
|
|
cmdCopy.Hidden = true
|
|
|
|
cmdCopy.Aliases = []string{}
|
|
|
|
return &cmdCopy
|
|
|
|
}
|