Added basic version of quiet mode to service create command

This commit is contained in:
Sreeram Venkitesh 2023-12-07 18:37:52 +05:30
parent bb1f899634
commit 2950b024ac
3 changed files with 10 additions and 1 deletions

View File

@ -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(

View File

@ -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
}

View File

@ -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{