diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index e03394c..c69b774 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -18,5 +18,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.55.2 + version: v1.57.2 diff --git a/cmd/puku/puku.go b/cmd/puku/puku.go index 8e447a2..413740c 100644 --- a/cmd/puku/puku.go +++ b/cmd/puku/puku.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "path/filepath" @@ -21,19 +20,6 @@ import ( "github.com/please-build/puku/work" ) -type outputFormat string - -// UnmarshalFlag implements the flags.Unmarshaler interface. -func (f *outputFormat) UnmarshalFlag(in string) error { - switch in { - case "json", "text": - *f = outputFormat(in) - default: - return fmt.Errorf("Flags error: Output format unrecognised") - } - return nil -} - var opts = struct { Usage string Verbosity clilogging.Verbosity `short:"v" long:"verbosity" description:"Verbosity of output (error, warning, notice, info, debug)" default:"info"` @@ -99,7 +85,7 @@ var funcs = map[string]func(conf *config.Config, plzConf *please.Config, orignal log.Fatalf("%v", err) } } else { - if err := sync.SyncToStdout(string(opts.Sync.Format), plzConf, g); err != nil { + if err := sync.SyncToStdout(opts.Sync.Format, plzConf, g); err != nil { log.Fatalf("%v", err) } } @@ -108,7 +94,7 @@ var funcs = map[string]func(conf *config.Config, plzConf *please.Config, orignal "lint": func(conf *config.Config, plzConf *please.Config, orignalWD string) int { paths := work.MustExpandPaths(orignalWD, opts.Lint.Args.Paths) - if err := generate.UpdateToStdout(string(opts.Lint.Format), plzConf, paths...); err != nil { + if err := generate.UpdateToStdout(opts.Lint.Format, plzConf, paths...); err != nil { log.Fatalf("%v", err) } return 0 @@ -135,7 +121,7 @@ var funcs = map[string]func(conf *config.Config, plzConf *please.Config, orignal log.Fatalf("%v", err) } } else { - if err := migrate.MigrateToStdout(string(opts.Migrate.Format), conf, plzConf, opts.Migrate.UpdateGoMod, opts.Migrate.Args.Modules, paths); err != nil { + if err := migrate.MigrateToStdout(opts.Migrate.Format, conf, plzConf, opts.Migrate.UpdateGoMod, opts.Migrate.Args.Modules, paths); err != nil { log.Fatalf("%v", err) } } @@ -149,7 +135,7 @@ var funcs = map[string]func(conf *config.Config, plzConf *please.Config, orignal log.Fatalf("%v", err) } } else { - if err := l.UpdateToStdout(string(opts.Licenses.Update.Format), paths); err != nil { + if err := l.UpdateToStdout(opts.Licenses.Update.Format, paths); err != nil { log.Fatalf("%v", err) } } diff --git a/licences/licences.go b/licences/licences.go index 5105414..04eb6a2 100644 --- a/licences/licences.go +++ b/licences/licences.go @@ -68,12 +68,16 @@ func getLicences(modPaths []string) (map[string][]string, error) { } func (l *Licenses) Update(paths []string) error { - l.update(paths) + if err := l.update(paths); err != nil { + return err + } return l.graph.FormatFiles() } func (l *Licenses) UpdateToStdout(format string, paths []string) error { - l.update(paths) + if err := l.update(paths); err != nil { + return err + } return l.graph.FormatFilesWithWriter(os.Stdout, format) } diff --git a/migrate/migrate.go b/migrate/migrate.go index cc1d4f5..4468faf 100644 --- a/migrate/migrate.go +++ b/migrate/migrate.go @@ -48,7 +48,6 @@ func Migrate(conf *config.Config, plzConf *please.Config, updateGoMod bool, modu return err } return m.graph.FormatFiles() - } func MigrateToStdout(format string, conf *config.Config, plzConf *please.Config, updateGoMod bool, modules, paths []string) error { diff --git a/sync/sync.go b/sync/sync.go index db712bc..56e0ff2 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -43,6 +43,7 @@ func Sync(plzConf *please.Config, g *graph.Graph) error { return s.graph.FormatFiles() } +// SyncToStdout constructs the syncer and outputs the synced build file to stdout. func SyncToStdout(format string, plzConf *please.Config, g *graph.Graph) error { s := newSyncer(plzConf, g) if err := s.sync(); err != nil {