add --verbose option for compatibility

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-06-22 11:44:56 +02:00
parent 6bfdfa8947
commit 46a65b8c77
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 12 additions and 2 deletions

View File

@ -25,6 +25,8 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/sirupsen/logrus"
"github.com/compose-spec/compose-go/cli" "github.com/compose-spec/compose-go/cli"
"github.com/compose-spec/compose-go/types" "github.com/compose-spec/compose-go/types"
dockercli "github.com/docker/cli/cli" dockercli "github.com/docker/cli/cli"
@ -196,8 +198,11 @@ func (o *projectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.Proj
// RootCommand returns the compose command with its child commands // RootCommand returns the compose command with its child commands
func RootCommand(contextType string, backend api.Service) *cobra.Command { func RootCommand(contextType string, backend api.Service) *cobra.Command {
opts := projectOptions{} opts := projectOptions{}
var ansi string var (
var noAnsi bool ansi string
noAnsi bool
verbose bool
)
command := &cobra.Command{ command := &cobra.Command{
Short: "Docker Compose", Short: "Docker Compose",
Use: "compose", Use: "compose",
@ -229,6 +234,9 @@ func RootCommand(contextType string, backend api.Service) *cobra.Command {
ansi = "never" ansi = "never"
fmt.Fprint(os.Stderr, aec.Apply("option '--no-ansi' is DEPRECATED ! Please use '--ansi' instead.\n", aec.RedF)) fmt.Fprint(os.Stderr, aec.Apply("option '--no-ansi' is DEPRECATED ! Please use '--ansi' instead.\n", aec.RedF))
} }
if verbose {
logrus.SetLevel(logrus.TraceLevel)
}
formatter.SetANSIMode(ansi) formatter.SetANSIMode(ansi)
if opts.WorkDir != "" { if opts.WorkDir != "" {
if opts.ProjectDir != "" { if opts.ProjectDir != "" {
@ -282,5 +290,7 @@ func RootCommand(contextType string, backend api.Service) *cobra.Command {
command.Flags().StringVar(&ansi, "ansi", "auto", `Control when to print ANSI control characters ("never"|"always"|"auto")`) command.Flags().StringVar(&ansi, "ansi", "auto", `Control when to print ANSI control characters ("never"|"always"|"auto")`)
command.Flags().BoolVar(&noAnsi, "no-ansi", false, `Do not print ANSI control characters (DEPRECATED)`) command.Flags().BoolVar(&noAnsi, "no-ansi", false, `Do not print ANSI control characters (DEPRECATED)`)
command.Flags().MarkHidden("no-ansi") //nolint:errcheck command.Flags().MarkHidden("no-ansi") //nolint:errcheck
command.Flags().BoolVar(&verbose, "verbose", false, "Show more output")
command.Flags().MarkHidden("verbose") //nolint:errcheck
return command return command
} }