Run is the main entry point for the controller.
()
| 40 | |
| 41 | // Run is the main entry point for the controller. |
| 42 | func Run() error { |
| 43 | // Check if first arg is a subcommand |
| 44 | if len(os.Args) > 1 { |
| 45 | switch os.Args[1] { |
| 46 | case "lint": |
| 47 | return linter.Run() |
| 48 | case "version": |
| 49 | return version.Run() |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | cfg, err := BuildConfigFromArgs(os.Args[1:]) |
| 54 | if err != nil { |
| 55 | var errs validator.ValidationErrors |
| 56 | if errors.As(err, &errs) { |
| 57 | for _, e := range errs { |
| 58 | log.Println(e.Translate(trans)) |
| 59 | } |
| 60 | } |
| 61 | return err |
| 62 | } |
| 63 | |
| 64 | return runController(cfg) |
| 65 | } |
| 66 | |
| 67 | // BuildConfigFromArgs parses CLI args and env vars, then builds config. |
| 68 | // Config file can be specified via --config flag or CONFIG env var. |
no test coverage detected