1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-07-17 01:42:37 +02:00

feat: check -q (#2232)

* feat: check -q

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* docs: cmd docs

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker
2021-05-20 22:47:32 -03:00
committed by GitHub
parent e5e7950986
commit 3a45a9182e
3 changed files with 15 additions and 0 deletions

View File

@ -2,8 +2,10 @@ package cmd
import (
"fmt"
"io"
"github.com/apex/log"
"github.com/apex/log/handlers/cli"
"github.com/caarlos0/ctrlc"
"github.com/fatih/color"
"github.com/goreleaser/goreleaser/internal/pipe/defaults"
@ -14,6 +16,7 @@ import (
type checkCmd struct {
cmd *cobra.Command
config string
quiet bool
deprecated bool
}
@ -27,6 +30,10 @@ func newCheckCmd() *checkCmd {
SilenceErrors: true,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if root.quiet {
log.SetHandler(cli.New(io.Discard))
}
cfg, err := loadConfig(root.config)
if err != nil {
return err
@ -55,6 +62,7 @@ func newCheckCmd() *checkCmd {
}
cmd.Flags().StringVarP(&root.config, "config", "f", "", "Configuration file to check")
cmd.Flags().BoolVarP(&root.quiet, "quiet", "q", false, "Quiet mode: no output")
cmd.Flags().BoolVar(&root.deprecated, "deprecated", false, "Force print the deprecation message - tests only")
_ = cmd.Flags().MarkHidden("deprecated")

View File

@ -30,6 +30,12 @@ func TestCheckConfigInvalid(t *testing.T) {
require.EqualError(t, cmd.cmd.Execute(), "invalid config: found 2 builds with the ID 'a', please fix your config")
}
func TestCheckConfigInvalidQuiet(t *testing.T) {
cmd := newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/invalid.yml", "-q"})
require.Error(t, cmd.cmd.Execute())
}
func TestCheckConfigDeprecated(t *testing.T) {
cmd := newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml", "--deprecated"})

View File

@ -11,6 +11,7 @@ goreleaser check [flags]
```
-f, --config string Configuration file to check
-h, --help help for check
-q, --quiet Quiet mode: no output
```
## Options inherited from parent commands