Skip to content

Commit

Permalink
Merge pull request #94 from Peefy/feat-add-queit-for-all-mod-cmd
Browse files Browse the repository at this point in the history
feat: add queit mode for all mod cmd
  • Loading branch information
Peefy authored Jun 11, 2024
2 parents dc2b9a8 + 85f65b8 commit 26f40e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cmd/kcl/commands/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,27 @@ var (

// NewModCmd returns the mod command.
func NewModCmd() *cobra.Command {
reporter.InitReporter()
cli, err := client.NewKpmClient()
if err != nil {
panic(err)
}
cmd := &cobra.Command{
Use: "mod",
Short: "KCL module management",
Long: modDesc,
Example: modExample,
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if quiet {
cli.SetLogWriter(nil)
}
return nil
},
}

cmd.PersistentFlags().BoolVarP(&quiet, "quiet", "q", false, "Set the quiet mode (no output)")

reporter.InitReporter()
cli, err := client.NewKpmClient()
if err != nil {
panic(err)
}
if quiet {
cli.SetLogWriter(nil)
}

cmd.AddCommand(NewModInitCmd(cli))
cmd.AddCommand(NewModAddCmd(cli))
cmd.AddCommand(NewModPkgCmd(cli))
Expand Down
3 changes: 3 additions & 0 deletions pkg/options/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func (o *RunOptions) Run() error {
}
}()
opts := CompileOptionFromCli(o)
if o.Quiet {
opts.SetLogWriter(nil)
}
if err != nil {
return err
}
Expand Down

0 comments on commit 26f40e6

Please sign in to comment.