Remove the hidden flag from version, added --version and -v flags to root command.

Signed-off-by: Shikachuu <zcmate@gmail.com>
This commit is contained in:
Shikachuu 2021-10-03 11:11:36 +02:00 committed by Nicolas De loof
parent 98fe57baac
commit fc8a433cee
2 changed files with 9 additions and 4 deletions

View File

@ -222,6 +222,7 @@ func RootCommand(backend api.Service) *cobra.Command {
ansi string
noAnsi bool
verbose bool
version bool
)
command := &cobra.Command{
Short: "Docker Compose",
@ -232,6 +233,9 @@ func RootCommand(backend api.Service) *cobra.Command {
if len(args) == 0 {
return cmd.Help()
}
if version {
return versionCommand().Execute()
}
_ = cmd.Help()
return dockercli.StatusError{
StatusCode: compose.CommandSyntaxFailure.ExitCode,
@ -304,6 +308,8 @@ func RootCommand(backend api.Service) *cobra.Command {
command.Flags().SetInterspersed(false)
opts.addProjectFlags(command.Flags())
command.Flags().StringVar(&ansi, "ansi", "auto", `Control when to print ANSI control characters ("never"|"always"|"auto")`)
command.Flags().BoolVarP(&version, "version", "v", false, "Show the Docker Compose version information")
command.Flags().MarkHidden("version") //nolint:errcheck
command.Flags().BoolVar(&noAnsi, "no-ansi", false, `Do not print ANSI control characters (DEPRECATED)`)
command.Flags().MarkHidden("no-ansi") //nolint:errcheck
command.Flags().BoolVar(&verbose, "verbose", false, "Show more output")

View File

@ -37,7 +37,6 @@ func versionCommand() *cobra.Command {
Use: "version",
Short: "Show the Docker Compose version information",
Args: cobra.MaximumNArgs(0),
Hidden: true,
RunE: func(cmd *cobra.Command, _ []string) error {
runVersion(opts)
return nil