From c8ebf40e78f57d77cc6895f65a6c064c5d749d1e Mon Sep 17 00:00:00 2001 From: Snider Date: Fri, 20 Mar 2026 12:24:39 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20IsFlag=20helper=20=E2=80=94=20cli.go=20?= =?UTF-8?q?now=20has=20zero=20string=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- pkg/core/cli.go | 3 +-- pkg/core/utils.go | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/core/cli.go b/pkg/core/cli.go index be8c91e..ede519d 100644 --- a/pkg/core/cli.go +++ b/pkg/core/cli.go @@ -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}) } } diff --git a/pkg/core/utils.go b/pkg/core/utils.go index 7fa5d81..99c9a8b 100644 --- a/pkg/core/utils.go +++ b/pkg/core/utils.go @@ -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:])