| 12 | var app *cli.App |
| 13 | |
| 14 | func init() { |
| 15 | app = cli.NewApp() |
| 16 | app.Usage = "composable all-in-one mail server" |
| 17 | app.Description = `Maddy is Mail Transfer agent (MTA), Mail Delivery Agent (MDA), Mail Submission |
| 18 | Agent (MSA), IMAP server and a set of other essential protocols/schemes |
| 19 | necessary to run secure email server implemented in one executable. |
| 20 | |
| 21 | This executable can be used to start the server ('run') and to manipulate |
| 22 | databases used by it (all other subcommands). |
| 23 | ` |
| 24 | app.Authors = []*cli.Author{ |
| 25 | { |
| 26 | Name: "Maddy Mail Server maintainers & contributors", |
| 27 | Email: "~foxcpp/maddy@lists.sr.ht", |
| 28 | }, |
| 29 | } |
| 30 | app.ExitErrHandler = func(c *cli.Context, err error) { |
| 31 | if err == nil { |
| 32 | return |
| 33 | } |
| 34 | |
| 35 | var exitErr cli.ExitCoder |
| 36 | if errors.As(err, &exitErr) { |
| 37 | if err.Error() != "" { |
| 38 | if _, ok := exitErr.(cli.ErrorFormatter); ok { |
| 39 | _, _ = fmt.Fprintf(os.Stderr, "Error: %+v\n", err) |
| 40 | } else { |
| 41 | _, _ = fmt.Fprintln(os.Stderr, "Error:", err) |
| 42 | } |
| 43 | } |
| 44 | cli.OsExiter(exitErr.ExitCode()) |
| 45 | return |
| 46 | } |
| 47 | } |
| 48 | app.EnableBashCompletion = true |
| 49 | app.Commands = []*cli.Command{ |
| 50 | { |
| 51 | Name: "generate-man", |
| 52 | Hidden: true, |
| 53 | Action: func(c *cli.Context) error { |
| 54 | man, err := app.ToMan() |
| 55 | if err != nil { |
| 56 | return err |
| 57 | } |
| 58 | fmt.Println(man) |
| 59 | return nil |
| 60 | }, |
| 61 | }, |
| 62 | { |
| 63 | Name: "generate-fish-completion", |
| 64 | Hidden: true, |
| 65 | Action: func(c *cli.Context) error { |
| 66 | cp, err := app.ToFishCompletion() |
| 67 | if err != nil { |
| 68 | return err |
| 69 | } |
| 70 | fmt.Println(cp) |
| 71 | return nil |