Skip to content

Commit

Permalink
Adds a "quiet" option to silence output to stdout/stderr (#30)
Browse files Browse the repository at this point in the history
* Adds a "quiet" option to silence output to stdout/stderr

* Update app.go

Co-authored-by: Patrick D'appollonio <[email protected]>

* Update slice/execute.go

Co-authored-by: Patrick D'appollonio <[email protected]>

Co-authored-by: Ian Seyer <[email protected]>
Co-authored-by: Patrick D'appollonio <[email protected]>
Co-authored-by: Patrick D'appollonio <[email protected]>
  • Loading branch information
4 people authored Feb 22, 2022
1 parent 90eafba commit 9a991d7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Flags:
--include-name strings resource name to include in the output (singular, case insensitive, glob supported)
-f, --input-file string the input file used to read the initial macro YAML file; if empty or "-", stdin is used
-o, --output-dir string the output directory used to output the splitted files
-q, --quiet silences all output to stdout/err when writing to files
-s, --skip-non-k8s if enabled, any YAMLs that don't contain at least an "apiVersion", "kind" and "metadata.name" will be excluded from the split
--sort-by-kind if enabled, resources are sorted by Kind, a la Helm, before saving them to disk
--stdout if enabled, no resource is written to disk and all resources are printed to stdout instead
Expand Down
1 change: 1 addition & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func root() *coral.Command {
rootCommand.Flags().StringVarP(&opts.GoTemplate, "template", "t", slice.DefaultTemplateName, "go template used to generate the file name when creating the resource files in the output directory")
rootCommand.Flags().BoolVar(&opts.DryRun, "dry-run", false, "if true, no files are created, but the potentially generated files will be printed as the command output")
rootCommand.Flags().BoolVar(&opts.DebugMode, "debug", false, "enable debug mode")
rootCommand.Flags().BoolVarP(&opts.Quiet, "quiet", "q", false, "if true, no output is written to stdout/err")
rootCommand.Flags().StringSliceVar(&opts.IncludedKinds, "include-kind", nil, "resource kind to include in the output (singular, case insensitive, glob supported)")
rootCommand.Flags().StringSliceVar(&opts.ExcludedKinds, "exclude-kind", nil, "resource kind to exclude in the output (singular, case insensitive, glob supported)")
rootCommand.Flags().StringSliceVar(&opts.IncludedNames, "include-name", nil, "resource name to include in the output (singular, case insensitive, glob supported)")
Expand Down
4 changes: 3 additions & 1 deletion slice/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ func (s *Split) store() error {
fmt.Fprintf(os.Stderr, "%d %s parsed to stdout.\n", s.fileCount, pluralize("file", s.fileCount))

default:
fmt.Fprintf(os.Stderr, "%d %s generated.\n", s.fileCount, pluralize("file", s.fileCount))
if !s.opts.Quiet {
fmt.Fprintf(os.Stderr, "%d %s generated.\n", s.fileCount, pluralize("file", s.fileCount))
}
}

return nil
Expand Down
1 change: 1 addition & 0 deletions slice/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Options struct {
GoTemplate string // the go template code to render the file names
DryRun bool // if true, no files are created
DebugMode bool // enables debug mode
Quiet bool //disables all writing to StdOut/StdErr

IncludedKinds []string
ExcludedKinds []string
Expand Down

0 comments on commit 9a991d7

Please sign in to comment.