Run executes the main program.
(ctx context.Context, args []string)
| 53 | |
| 54 | // Run executes the main program. |
| 55 | func Run(ctx context.Context, args []string) error { |
| 56 | // Shift off subcommand from the argument list, if available. |
| 57 | var cmd string |
| 58 | if len(args) > 0 { |
| 59 | cmd, args = args[0], args[1:] |
| 60 | } |
| 61 | |
| 62 | // Delegate subcommands to their own Run() methods. |
| 63 | switch cmd { |
| 64 | case "dial": |
| 65 | return (&DialCommand{}).Run(ctx, args) |
| 66 | case "", "-h", "help": |
| 67 | usage() |
| 68 | return flag.ErrHelp |
| 69 | default: |
| 70 | return fmt.Errorf("wtf %s: unknown command", cmd) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // usage prints the top-level CLI usage message. |
| 75 | func usage() { |