| 104 | } |
| 105 | |
| 106 | func init() { |
| 107 | maddycli.AddGlobalFlag( |
| 108 | &cli.PathFlag{ |
| 109 | Name: "config", |
| 110 | Usage: "Configuration file to use", |
| 111 | EnvVars: []string{"MADDY_CONFIG"}, |
| 112 | Value: filepath.Join(ConfigDirectory, "maddy.conf"), |
| 113 | }, |
| 114 | ) |
| 115 | maddycli.AddGlobalFlag(&cli.BoolFlag{ |
| 116 | Name: "debug", |
| 117 | Usage: "enable debug logging early", |
| 118 | Destination: &log.DefaultLogger.Debug, |
| 119 | }) |
| 120 | maddycli.AddSubcommand(&cli.Command{ |
| 121 | Name: "verify-config", |
| 122 | Usage: "Check configuration file for errors", |
| 123 | Flags: []cli.Flag{ |
| 124 | &cli.BoolFlag{ |
| 125 | Name: "debug", |
| 126 | Usage: "enable debug logging early", |
| 127 | Destination: &log.DefaultLogger.Debug, |
| 128 | }, |
| 129 | }, |
| 130 | Action: VerifyConfig, |
| 131 | }) |
| 132 | maddycli.AddSubcommand(&cli.Command{ |
| 133 | Name: "run", |
| 134 | Usage: "Start the server", |
| 135 | Flags: []cli.Flag{ |
| 136 | &cli.StringFlag{ |
| 137 | Name: "libexec", |
| 138 | Value: DefaultLibexecDirectory, |
| 139 | Usage: "path to the libexec directory", |
| 140 | Destination: &config.LibexecDirectory, |
| 141 | }, |
| 142 | &cli.StringSliceFlag{ |
| 143 | Name: "log", |
| 144 | Usage: "default logging target(s)", |
| 145 | Value: cli.NewStringSlice("stderr"), |
| 146 | }, |
| 147 | &cli.BoolFlag{ |
| 148 | Name: "v", |
| 149 | Usage: "print version and build metadata, then exit", |
| 150 | Hidden: true, |
| 151 | }, |
| 152 | }, |
| 153 | Action: Run, |
| 154 | }) |
| 155 | maddycli.AddSubcommand(&cli.Command{ |
| 156 | Name: "version", |
| 157 | Usage: "Print version and build metadata, then exit", |
| 158 | Action: func(c *cli.Context) error { |
| 159 | fmt.Println(BuildInfo()) |
| 160 | return nil |
| 161 | }, |
| 162 | }) |
| 163 | |