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(
|
2016-12-01 11:08:24 -05:00
|
|
|
// checkpoint
|
|
|
|
checkpoint.NewCheckpointCommand(dockerCli),
|
|
|
|
|
2017-05-08 13:36:04 -04:00
|
|
|
// config
|
|
|
|
config.NewConfigCommand(dockerCli),
|
|
|
|
|
2016-12-01 11:08:24 -05:00
|
|
|
// container
|
2016-06-23 13:03:40 -04:00
|
|
|
container.NewContainerCommand(dockerCli),
|
2016-09-08 13:11:39 -04:00
|
|
|
container.NewRunCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// image
|
|
|
|
image.NewImageCommand(dockerCli),
|
2016-09-08 13:11:39 -04:00
|
|
|
image.NewBuildCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
2018-08-17 05:51:04 -04:00
|
|
|
// builder
|
|
|
|
builder.NewBuilderCommand(dockerCli),
|
|
|
|
|
2017-06-15 14:41:54 -04:00
|
|
|
// manifest
|
|
|
|
manifest.NewManifestCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// network
|
2016-09-08 13:11:39 -04:00
|
|
|
network.NewNetworkCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
2017-06-15 14:41:54 -04:00
|
|
|
// node
|
|
|
|
node.NewNodeCommand(dockerCli),
|
|
|
|
|
2016-12-01 11:08:24 -05:00
|
|
|
// plugin
|
|
|
|
plugin.NewPluginCommand(dockerCli),
|
|
|
|
|
|
|
|
// registry
|
2016-09-08 13:11:39 -04:00
|
|
|
registry.NewLoginCommand(dockerCli),
|
|
|
|
registry.NewLogoutCommand(dockerCli),
|
2016-08-29 09:59:41 -04:00
|
|
|
registry.NewSearchCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// secret
|
|
|
|
secret.NewSecretCommand(dockerCli),
|
|
|
|
|
|
|
|
// service
|
|
|
|
service.NewServiceCommand(dockerCli),
|
|
|
|
|
|
|
|
// system
|
|
|
|
system.NewSystemCommand(dockerCli),
|
2016-09-08 13:11:39 -04:00
|
|
|
system.NewVersionCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// stack
|
|
|
|
stack.NewStackCommand(dockerCli),
|
|
|
|
|
|
|
|
// swarm
|
|
|
|
swarm.NewSwarmCommand(dockerCli),
|
|
|
|
|
2017-08-24 18:43:55 -04:00
|
|
|
// trust
|
|
|
|
trust.NewTrustCommand(dockerCli),
|
|
|
|
|
2016-12-01 11:08:24 -05:00
|
|
|
// volume
|
2016-09-08 13:11:39 -04:00
|
|
|
volume.NewVolumeCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
2018-11-09 09:10:41 -05:00
|
|
|
// context
|
|
|
|
context.NewContextCommand(dockerCli),
|
|
|
|
|
2016-12-01 11:08:24 -05:00
|
|
|
// legacy commands may be hidden
|
|
|
|
hide(system.NewEventsCommand(dockerCli)),
|
2016-09-19 13:38:58 -04:00
|
|
|
hide(system.NewInfoCommand(dockerCli)),
|
2016-12-01 11:08:24 -05:00
|
|
|
hide(system.NewInspectCommand(dockerCli)),
|
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.NewExecCommand(dockerCli)),
|
|
|
|
hide(container.NewExportCommand(dockerCli)),
|
|
|
|
hide(container.NewKillCommand(dockerCli)),
|
|
|
|
hide(container.NewLogsCommand(dockerCli)),
|
|
|
|
hide(container.NewPauseCommand(dockerCli)),
|
|
|
|
hide(container.NewPortCommand(dockerCli)),
|
|
|
|
hide(container.NewPsCommand(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.NewImagesCommand(dockerCli)),
|
|
|
|
hide(image.NewImportCommand(dockerCli)),
|
|
|
|
hide(image.NewLoadCommand(dockerCli)),
|
|
|
|
hide(image.NewPullCommand(dockerCli)),
|
|
|
|
hide(image.NewPushCommand(dockerCli)),
|
|
|
|
hide(image.NewRemoveCommand(dockerCli)),
|
|
|
|
hide(image.NewSaveCommand(dockerCli)),
|
|
|
|
hide(image.NewTagCommand(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
|
|
|
|
}
|