feat: IsFlag helper — cli.go now has zero string imports

core.IsFlag(arg) checks if an argument starts with a dash.
Cli.go no longer imports strings — all string ops via utils.go helpers.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-20 12:24:39 +00:00
parent c3f457c151
commit c8ebf40e78
2 changed files with 10 additions and 2 deletions

View file

@ -16,7 +16,6 @@ package core
import (
"io"
"os"
"strings"
)
// Cli is the CLI surface for the Core command tree.
@ -89,7 +88,7 @@ func (cl *Cli) Run(args ...string) Result[any] {
} else {
opts = append(opts, Option{K: key, V: true})
}
} else if !strings.HasPrefix(arg, "-") {
} else if !IsFlag(arg) {
opts = append(opts, Option{K: "_arg", V: arg})
}
}

View file

@ -31,6 +31,15 @@ func JoinPath(segments ...string) string {
return strings.Join(segments, "/")
}
// IsFlag returns true if the argument starts with a dash.
//
// core.IsFlag("--verbose") // true
// core.IsFlag("-v") // true
// core.IsFlag("deploy") // false
func IsFlag(arg string) bool {
return strings.HasPrefix(arg, "-")
}
// FilterArgs removes empty strings and Go test runner flags from an argument list.
//
// clean := core.FilterArgs(os.Args[1:])