cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
cmd/pint/config.go
32lines · modecode
| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
| 6 | |
| 7 | "github.com/cloudflare/pint/internal/config" |
| 8 | |
| 9 | "github.com/urfave/cli/v2" |
| 10 | ) |
| 11 | |
| 12 | var configCmd = &cli.Command{ |
| 13 | Name: "config", |
| 14 | Usage: "Parse and print used config.", |
| 15 | Action: actionConfig, |
| 16 | } |
| 17 | |
| 18 | func actionConfig(c *cli.Context) (err error) { |
| 19 | err = initLogger(c.String(logLevelFlag), c.Bool(noColorFlag)) |
| 20 | if err != nil { |
| 21 | return fmt.Errorf("failed to set log level: %w", err) |
| 22 | } |
| 23 | |
| 24 | cfg, _, err := config.Load(c.Path(configFlag), c.IsSet(configFlag)) |
| 25 | if err != nil { |
| 26 | return fmt.Errorf("failed to load config file %q: %w", c.Path(configFlag), err) |
| 27 | } |
| 28 | |
| 29 | fmt.Fprintln(os.Stderr, cfg.String()) |
| 30 | |
| 31 | return nil |
| 32 | } |
| 33 | |