shiftFlags prepends all the arguments (global flags) passed before the given mode to the list of arguments after that mode, and returns that list.
(mode string)
| 354 | // shiftFlags prepends all the arguments (global flags) passed before the given |
| 355 | // mode to the list of arguments after that mode, and returns that list. |
| 356 | func shiftFlags(mode string) []string { |
| 357 | modePos := 0 |
| 358 | for k, v := range os.Args { |
| 359 | if v == mode { |
| 360 | modePos = k |
| 361 | break |
| 362 | } |
| 363 | } |
| 364 | globalFlags := os.Args[1:modePos] |
| 365 | return append(globalFlags, os.Args[modePos+1:]...) |
| 366 | } |
| 367 | |
| 368 | // Errorf prints to Stderr, regardless of FlagVerbose. |
| 369 | func Errorf(format string, args ...interface{}) { |