|
1 | 1 | package commands |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "os" |
5 | | - |
6 | 4 | "github.com/docker/cli/cli/command" |
7 | | - "github.com/docker/cli/cli/command/builder" |
8 | | - "github.com/docker/cli/cli/command/checkpoint" |
9 | | - "github.com/docker/cli/cli/command/config" |
10 | | - "github.com/docker/cli/cli/command/container" |
11 | | - "github.com/docker/cli/cli/command/context" |
12 | | - "github.com/docker/cli/cli/command/image" |
13 | | - "github.com/docker/cli/cli/command/manifest" |
14 | | - "github.com/docker/cli/cli/command/network" |
15 | | - "github.com/docker/cli/cli/command/node" |
16 | | - "github.com/docker/cli/cli/command/plugin" |
17 | | - "github.com/docker/cli/cli/command/registry" |
18 | | - "github.com/docker/cli/cli/command/secret" |
19 | | - "github.com/docker/cli/cli/command/service" |
20 | | - "github.com/docker/cli/cli/command/stack" |
21 | | - "github.com/docker/cli/cli/command/swarm" |
22 | | - "github.com/docker/cli/cli/command/system" |
23 | | - "github.com/docker/cli/cli/command/trust" |
24 | | - "github.com/docker/cli/cli/command/volume" |
| 5 | + _ "github.com/docker/cli/cli/command/builder" |
| 6 | + _ "github.com/docker/cli/cli/command/checkpoint" |
| 7 | + _ "github.com/docker/cli/cli/command/config" |
| 8 | + _ "github.com/docker/cli/cli/command/container" |
| 9 | + _ "github.com/docker/cli/cli/command/context" |
| 10 | + _ "github.com/docker/cli/cli/command/image" |
| 11 | + _ "github.com/docker/cli/cli/command/manifest" |
| 12 | + _ "github.com/docker/cli/cli/command/network" |
| 13 | + _ "github.com/docker/cli/cli/command/node" |
| 14 | + _ "github.com/docker/cli/cli/command/plugin" |
| 15 | + _ "github.com/docker/cli/cli/command/registry" |
| 16 | + _ "github.com/docker/cli/cli/command/secret" |
| 17 | + _ "github.com/docker/cli/cli/command/service" |
| 18 | + _ "github.com/docker/cli/cli/command/stack" |
| 19 | + _ "github.com/docker/cli/cli/command/swarm" |
| 20 | + _ "github.com/docker/cli/cli/command/system" |
| 21 | + _ "github.com/docker/cli/cli/command/trust" |
| 22 | + _ "github.com/docker/cli/cli/command/volume" |
| 23 | + "github.com/docker/cli/internal/commands" |
25 | 24 | "github.com/spf13/cobra" |
26 | 25 | ) |
27 | 26 |
|
28 | | -// AddCommands adds all the commands from cli/command to the root command |
29 | | -func AddCommands(cmd *cobra.Command, dockerCli command.Cli) { |
30 | | - cmd.AddCommand( |
31 | | - // commonly used shorthands |
32 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
33 | | - container.NewRunCommand(dockerCli), |
34 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
35 | | - container.NewExecCommand(dockerCli), |
36 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
37 | | - container.NewPsCommand(dockerCli), |
38 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
39 | | - image.NewBuildCommand(dockerCli), |
40 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
41 | | - image.NewPullCommand(dockerCli), |
42 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
43 | | - image.NewPushCommand(dockerCli), |
44 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
45 | | - image.NewImagesCommand(dockerCli), |
46 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
47 | | - registry.NewLoginCommand(dockerCli), |
48 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
49 | | - registry.NewLogoutCommand(dockerCli), |
50 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
51 | | - registry.NewSearchCommand(dockerCli), |
52 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
53 | | - system.NewVersionCommand(dockerCli), |
54 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
55 | | - system.NewInfoCommand(dockerCli), |
56 | | - |
57 | | - // management commands |
58 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
59 | | - builder.NewBakeStubCommand(dockerCli), |
60 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
61 | | - builder.NewBuilderCommand(dockerCli), |
62 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
63 | | - checkpoint.NewCheckpointCommand(dockerCli), |
64 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
65 | | - container.NewContainerCommand(dockerCli), |
66 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
67 | | - context.NewContextCommand(dockerCli), |
68 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
69 | | - image.NewImageCommand(dockerCli), |
70 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
71 | | - manifest.NewManifestCommand(dockerCli), |
72 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
73 | | - network.NewNetworkCommand(dockerCli), |
74 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
75 | | - plugin.NewPluginCommand(dockerCli), |
76 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
77 | | - system.NewSystemCommand(dockerCli), |
78 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
79 | | - trust.NewTrustCommand(dockerCli), |
80 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
81 | | - volume.NewVolumeCommand(dockerCli), |
82 | | - |
83 | | - // orchestration (swarm) commands |
84 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
85 | | - config.NewConfigCommand(dockerCli), |
86 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
87 | | - node.NewNodeCommand(dockerCli), |
88 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
89 | | - secret.NewSecretCommand(dockerCli), |
90 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
91 | | - service.NewServiceCommand(dockerCli), |
92 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
93 | | - stack.NewStackCommand(dockerCli), |
94 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
95 | | - swarm.NewSwarmCommand(dockerCli), |
96 | | - |
97 | | - // legacy commands may be hidden |
98 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
99 | | - hide(container.NewAttachCommand(dockerCli)), |
100 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
101 | | - hide(container.NewCommitCommand(dockerCli)), |
102 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
103 | | - hide(container.NewCopyCommand(dockerCli)), |
104 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
105 | | - hide(container.NewCreateCommand(dockerCli)), |
106 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
107 | | - hide(container.NewDiffCommand(dockerCli)), |
108 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
109 | | - hide(container.NewExportCommand(dockerCli)), |
110 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
111 | | - hide(container.NewKillCommand(dockerCli)), |
112 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
113 | | - hide(container.NewLogsCommand(dockerCli)), |
114 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
115 | | - hide(container.NewPauseCommand(dockerCli)), |
116 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
117 | | - hide(container.NewPortCommand(dockerCli)), |
118 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
119 | | - hide(container.NewRenameCommand(dockerCli)), |
120 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
121 | | - hide(container.NewRestartCommand(dockerCli)), |
122 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
123 | | - hide(container.NewRmCommand(dockerCli)), |
124 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
125 | | - hide(container.NewStartCommand(dockerCli)), |
126 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
127 | | - hide(container.NewStatsCommand(dockerCli)), |
128 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
129 | | - hide(container.NewStopCommand(dockerCli)), |
130 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
131 | | - hide(container.NewTopCommand(dockerCli)), |
132 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
133 | | - hide(container.NewUnpauseCommand(dockerCli)), |
134 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
135 | | - hide(container.NewUpdateCommand(dockerCli)), |
136 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
137 | | - hide(container.NewWaitCommand(dockerCli)), |
138 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
139 | | - hide(image.NewHistoryCommand(dockerCli)), |
140 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
141 | | - hide(image.NewImportCommand(dockerCli)), |
142 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
143 | | - hide(image.NewLoadCommand(dockerCli)), |
144 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
145 | | - hide(image.NewRemoveCommand(dockerCli)), |
146 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
147 | | - hide(image.NewSaveCommand(dockerCli)), |
148 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
149 | | - hide(image.NewTagCommand(dockerCli)), |
150 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
151 | | - hide(system.NewEventsCommand(dockerCli)), |
152 | | - //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) |
153 | | - hide(system.NewInspectCommand(dockerCli)), |
154 | | - ) |
155 | | -} |
156 | | - |
157 | | -func hide(cmd *cobra.Command) *cobra.Command { |
158 | | - // If the environment variable with name "DOCKER_HIDE_LEGACY_COMMANDS" is not empty, |
159 | | - // these legacy commands (such as `docker ps`, `docker exec`, etc) |
160 | | - // will not be shown in output console. |
161 | | - if os.Getenv("DOCKER_HIDE_LEGACY_COMMANDS") == "" { |
162 | | - return cmd |
| 27 | +func AddCommands(cmd *cobra.Command, dockerCLI command.Cli) { |
| 28 | + for _, c := range commands.Commands() { |
| 29 | + cmd.AddCommand(c(dockerCLI)) |
163 | 30 | } |
164 | | - cmdCopy := *cmd |
165 | | - cmdCopy.Hidden = true |
166 | | - cmdCopy.Aliases = []string{} |
167 | | - return &cmdCopy |
168 | 31 | } |
0 commit comments