Skip to content

Commit

Permalink
feat: added option to quiet output (#387)
Browse files Browse the repository at this point in the history
<!--

Describe in detail the changes you are proposing, and the rationale.

-->

<!--

Link all GitHub issues fixed by this PR, and add references to prior
related PRs.

-->

Fixes #

### NEW FEATURES | UPGRADE NOTES | ENHANCEMENTS | BUG FIXES |
EXPERIMENTS

<!--

Write a short description of your changes. Examples:

- Fixed a bug
- Added a new feature
- Updated documentation

--> 

-
  • Loading branch information
demeyerthom authored Apr 5, 2024
2 parents 45aeea7 + fd98bb7 commit ae4b777
Show file tree
Hide file tree
Showing 32 changed files with 72 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20240405-090340.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: Added option to quiet log outputs
time: 2024-04-05T09:03:40.705290796+02:00
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ MACH composer is a framework that you use to orchestrate and extend modern digit

```
-h, --help help for mach-composer
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ mach-composer apply [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ mach-composer cloud [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ mach-composer cloud add-organization-user [email-address] [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_cloud_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ mach-composer cloud config [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ mach-composer cloud create-api-client [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ mach-composer cloud create-component [name] [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ mach-composer cloud create-organization [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_cloud_create-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ mach-composer cloud create-project [key] [name] [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ mach-composer cloud describe-component-versions [name] [version] [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ mach-composer cloud list-api-clients [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ mach-composer cloud list-component-versions [name] [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ mach-composer cloud list-components [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ mach-composer cloud list-organization-users [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ mach-composer cloud list-organizations [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_cloud_list-projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ mach-composer cloud list-projects [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_cloud_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ mach-composer cloud login [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ mach-composer cloud register-component-version [name] [version] [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ mach-composer cloud update-component [key] [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ mach-composer components [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_generate.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ mach-composer generate [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ mach-composer graph [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ mach-composer init [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ mach-composer plan [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ mach-composer schema [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_show-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ mach-composer show-plan [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_sites.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ mach-composer sites [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ mach-composer terraform [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ mach-composer update [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
3 changes: 2 additions & 1 deletion docs/src/reference/cli/mach-composer_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ mach-composer version [flags]
### Options inherited from parent commands

```
--verbose Verbose output.
-q, --quiet Quiet output. This is equal to setting log levels to error and higher
-v, --verbose Verbose output. This is equal to setting log levels to debug and higher
```

### SEE ALSO
Expand Down
10 changes: 9 additions & 1 deletion internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ var (
panic(err)
}

quiet, err := cmd.Flags().GetBool("quiet")
if err != nil {
panic(err)
}

logger := zerolog.New(os.Stdout)
if verbose {
logger = logger.Level(zerolog.TraceLevel)
} else if quiet {
logger = logger.Level(zerolog.ErrorLevel)
} else {
logger = logger.Level(zerolog.InfoLevel)
}
Expand Down Expand Up @@ -58,7 +65,8 @@ var (
)

func init() {
RootCmd.PersistentFlags().BoolP("verbose", "", false, "Verbose output.")
RootCmd.PersistentFlags().BoolP("verbose", "v", false, "Verbose output. This is equal to setting log levels to debug and higher")
RootCmd.PersistentFlags().BoolP("quiet", "q", false, "Quiet output. This is equal to setting log levels to error and higher")
RootCmd.AddCommand(applyCmd)
RootCmd.AddCommand(cloudcmd.CloudCmd)
RootCmd.AddCommand(componentsCmd)
Expand Down

0 comments on commit ae4b777

Please sign in to comment.