Skip to content

Commit

Permalink
Remove the hidden flag from the version command, added --version and …
Browse files Browse the repository at this point in the history
…-v flags to root command.
  • Loading branch information
Shikachuu committed Oct 4, 2021
1 parent fdb90ca commit e9a3c8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 6 additions & 0 deletions cmd/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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")
Expand Down
7 changes: 3 additions & 4 deletions cmd/compose/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ type versionOptions struct {
func versionCommand() *cobra.Command {
opts := versionOptions{}
cmd := &cobra.Command{
Use: "version",
Short: "Show the Docker Compose version information",
Args: cobra.MaximumNArgs(0),
Hidden: true,
Use: "version",
Short: "Show the Docker Compose version information",
Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, _ []string) error {
runVersion(opts)
return nil
Expand Down

0 comments on commit e9a3c8b

Please sign in to comment.