Skip to content

Commit

Permalink
feat: add queit mode for all mod and run cmd
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Jun 11, 2024
1 parent 473af00 commit 85f65b8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 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
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
kcl-lang.io/kcl-go v0.9.0-beta.1
kcl-lang.io/kcl-openapi v0.6.1
kcl-lang.io/kcl-playground v0.5.1
kcl-lang.io/kpm v0.9.0-beta.1.0.20240605035613-c5c5085800b4
kcl-lang.io/kpm v0.9.0-rc.1
)

require (
Expand All @@ -29,7 +29,6 @@ require (
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
github.com/containers/ocicrypt v1.1.10 // indirect
github.com/containers/storage v1.54.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/emicklei/proto v1.13.2 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
Expand All @@ -53,12 +52,9 @@ require (
github.com/moby/sys/user v0.1.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/urfave/cli/v2 v2.25.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
Expand Down
20 changes: 2 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -868,9 +867,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
Expand Down Expand Up @@ -937,18 +934,13 @@ github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZ
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk=
github.com/urfave/cli/v2 v2.25.0 h1:ykdZKuQey2zq0yin/l7JOm9Mh+pg72ngYMeB0ABn6q8=
github.com/urfave/cli/v2 v2.25.0/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -1691,16 +1683,8 @@ kcl-lang.io/kcl-openapi v0.6.1 h1:iPH0EvPgDGZS5Lk00/Su5Av6AQP5IBG8f7gAUyevkHE=
kcl-lang.io/kcl-openapi v0.6.1/go.mod h1:Ai9mFztCVKkRSFabczO/r5hCNdqaNtAc2ZIRxTeV0Mk=
kcl-lang.io/kcl-playground v0.5.1 h1:MKQQUHgt4+2QyU2NVwa73oksOaBJGDi4keGoggA0MiU=
kcl-lang.io/kcl-playground v0.5.1/go.mod h1:IFmnlw7m011ccX8OidMUfnnN2u/TWdtQGxyABRTbmow=
kcl-lang.io/kpm v0.9.0-beta.1 h1:buc7yp6RR3MJPG0Un6IkkCpQaVPF8LnwgZtluY0a6dA=
kcl-lang.io/kpm v0.9.0-beta.1/go.mod h1:QJNbc1+go6OXAhiiBHJ7GAjYJ1AC5wLmKAmDS9o5n+k=
kcl-lang.io/kpm v0.9.0-beta.1.0.20240530104317-7a35562e78a2 h1:c/xCUaE/5rnN4FQjgh+Hd0QGl2KmeWxuibgtsjr+y40=
kcl-lang.io/kpm v0.9.0-beta.1.0.20240530104317-7a35562e78a2/go.mod h1:QJNbc1+go6OXAhiiBHJ7GAjYJ1AC5wLmKAmDS9o5n+k=
kcl-lang.io/kpm v0.9.0-beta.1.0.20240604083117-d7258bd4bbf0 h1:t5Z8qa9DzZVG8yLR95rYTOeWhFjUZi+aa06Oxw27jk0=
kcl-lang.io/kpm v0.9.0-beta.1.0.20240604083117-d7258bd4bbf0/go.mod h1:QJNbc1+go6OXAhiiBHJ7GAjYJ1AC5wLmKAmDS9o5n+k=
kcl-lang.io/kpm v0.9.0-beta.1.0.20240604093242-4244558de99a h1:2Y/Ek+TgDFMzq2dlbiRNAc2LXgeOByzWRPSzTSasFjE=
kcl-lang.io/kpm v0.9.0-beta.1.0.20240604093242-4244558de99a/go.mod h1:QJNbc1+go6OXAhiiBHJ7GAjYJ1AC5wLmKAmDS9o5n+k=
kcl-lang.io/kpm v0.9.0-beta.1.0.20240605035613-c5c5085800b4 h1:G4hkxgAQcxYt5vOIfma944KFLcMi6da7b8SnDRw9Cmg=
kcl-lang.io/kpm v0.9.0-beta.1.0.20240605035613-c5c5085800b4/go.mod h1:QJNbc1+go6OXAhiiBHJ7GAjYJ1AC5wLmKAmDS9o5n+k=
kcl-lang.io/kpm v0.9.0-rc.1 h1:Qz/l3uxZPe04no5fQ/vRfct+yr2dPRufjFX9r6iLee0=
kcl-lang.io/kpm v0.9.0-rc.1/go.mod h1:QJNbc1+go6OXAhiiBHJ7GAjYJ1AC5wLmKAmDS9o5n+k=
kcl-lang.io/lib v0.9.0-beta.1 h1:oO/3h5Ubk61LKVnE7A9xlV4FfSfKa6Jv+KNsoHMcnNc=
kcl-lang.io/lib v0.9.0-beta.1/go.mod h1:ubsalGXxJaa5II/EsHmsI/tL2EluYHIcW+BwzQPt+uY=
oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=
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 85f65b8

Please sign in to comment.