Add focused CLI argument helpers

This commit is contained in:
2026-05-31 03:31:57 +00:00
parent f2ec7bd11e
commit a973d0912d
5 changed files with 127 additions and 14 deletions

View File

@@ -82,3 +82,22 @@ func rejectExtraArgs(stderr io.Writer, command string, args []string) bool {
fmt.Fprintf(stderr, "%s: %s does not accept arguments: %s\n", app.Name, command, strings.Join(args, " "))
return true
}
func parseOptionalPathArg(stderr io.Writer, command string, args []string) (string, bool) {
if len(args) > 1 {
fmt.Fprintf(stderr, "%s: %s accepts at most one path\n", app.Name, command)
return "", false
}
if len(args) == 0 {
return "", true
}
return args[0], true
}
func rejectPositionalArgs(stderr io.Writer, command string, args []string) bool {
if len(args) == 0 {
return false
}
fmt.Fprintf(stderr, "%s: %s does not accept positional arguments: %v\n", app.Name, command, args)
return true
}