diff --git a/pkg/kn/commands/service/create.go b/pkg/kn/commands/service/create.go index 0657c2c54..a10053d7d 100644 --- a/pkg/kn/commands/service/create.go +++ b/pkg/kn/commands/service/create.go @@ -148,7 +148,13 @@ func NewServiceCreateCommand(p *commands.KnParams) *cobra.Command { return err } - out := cmd.OutOrStdout() + var out io.Writer + if p.QuietMode { + out = io.Discard + } else { + out = cmd.OutOrStdout() + } + if serviceExists { if !editFlags.ForceCreate { return fmt.Errorf( diff --git a/pkg/kn/commands/types.go b/pkg/kn/commands/types.go index 67621e0c1..80b049d21 100644 --- a/pkg/kn/commands/types.go +++ b/pkg/kn/commands/types.go @@ -70,6 +70,8 @@ type KnParams struct { // General global options LogHTTP bool + QuietMode bool + // Set this if you want to nail down the namespace fixedCurrentNamespace string } diff --git a/pkg/kn/root/root.go b/pkg/kn/root/root.go index 1b3abe152..af0e55ea3 100644 --- a/pkg/kn/root/root.go +++ b/pkg/kn/root/root.go @@ -92,6 +92,7 @@ Find more information about Knative at: https://knative.dev`, rootName), rootCmd.PersistentFlags().StringVar(&p.KubeAsUID, "as-uid", "", "uid to impersonate for the operation") rootCmd.PersistentFlags().StringArrayVar(&p.KubeAsGroup, "as-group", []string{}, "group to impersonate for the operation, this flag can be repeated to specify multiple groups") flags.AddBothBoolFlags(rootCmd.PersistentFlags(), &p.LogHTTP, "log-http", "", false, "log http traffic") + rootCmd.PersistentFlags().BoolVarP(&p.QuietMode, "quiet-mode", "q", false, "run commands in quiet mode") // Grouped commands groups := templates.CommandGroups{