mirror of https://github.com/docker/compose.git
only display experimental warning on command error
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
9dba841611
commit
58e495c60b
|
@ -17,8 +17,6 @@
|
||||||
package compose
|
package compose
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"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"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -27,6 +25,9 @@ import (
|
||||||
"github.com/docker/compose-cli/api/context/store"
|
"github.com/docker/compose-cli/api/context/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Warning is a global warning to be displayed to user on command failure
|
||||||
|
var Warning string
|
||||||
|
|
||||||
type projectOptions struct {
|
type projectOptions struct {
|
||||||
ProjectName string
|
ProjectName string
|
||||||
Profiles []string
|
Profiles []string
|
||||||
|
@ -99,7 +100,8 @@ func Command(contextType string) *cobra.Command {
|
||||||
TraverseChildren: true,
|
TraverseChildren: true,
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if contextType == store.DefaultContextType || contextType == store.LocalContextType {
|
if contextType == store.DefaultContextType || contextType == store.LocalContextType {
|
||||||
fmt.Println("The new 'docker compose' command is currently experimental. To provide feedback or request new features please open issues at https://github.com/docker/compose-cli")
|
Warning = "The new 'docker compose' command is currently experimental. " +
|
||||||
|
"To provide feedback or request new features please open issues at https://github.com/docker/compose-cli"
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -258,6 +258,11 @@ func exit(ctx string, err error, ctype string) {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(errdefs.ExitCodeLoginRequired)
|
os.Exit(errdefs.ExitCodeLoginRequired)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if compose.Warning != "" {
|
||||||
|
fmt.Fprintln(os.Stderr, compose.Warning)
|
||||||
|
}
|
||||||
|
|
||||||
if errors.Is(err, errdefs.ErrNotImplemented) {
|
if errors.Is(err, errdefs.ErrNotImplemented) {
|
||||||
name := metrics.GetCommand(os.Args[1:])
|
name := metrics.GetCommand(os.Args[1:])
|
||||||
fmt.Fprintf(os.Stderr, "Command %q not available in current context (%s)\n", name, ctx)
|
fmt.Fprintf(os.Stderr, "Command %q not available in current context (%s)\n", name, ctx)
|
||||||
|
|
Loading…
Reference in New Issue