(context *cli.Context, expected, checkType int)
| 21 | ) |
| 22 | |
| 23 | func checkArgs(context *cli.Context, expected, checkType int) error { |
| 24 | var err error |
| 25 | cmdName := context.Command.Name |
| 26 | switch checkType { |
| 27 | case exactArgs: |
| 28 | if context.NArg() != expected { |
| 29 | err = fmt.Errorf("%s: %q requires exactly %d argument(s)", os.Args[0], cmdName, expected) |
| 30 | } |
| 31 | case minArgs: |
| 32 | if context.NArg() < expected { |
| 33 | err = fmt.Errorf("%s: %q requires a minimum of %d argument(s)", os.Args[0], cmdName, expected) |
| 34 | } |
| 35 | case maxArgs: |
| 36 | if context.NArg() > expected { |
| 37 | err = fmt.Errorf("%s: %q requires a maximum of %d argument(s)", os.Args[0], cmdName, expected) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | if err != nil { |
| 42 | fmt.Printf("Incorrect Usage.\n\n") |
| 43 | _ = cli.ShowCommandHelp(context, cmdName) |
| 44 | return err |
| 45 | } |
| 46 | return nil |
| 47 | } |
| 48 | |
| 49 | func logrusToStderr() bool { |
| 50 | l, ok := logrus.StandardLogger().Out.(*os.File) |
no outgoing calls
no test coverage detected
searching dependent graphs…