feat: JoinPath helper — joins segments with /

core.JoinPath("deploy", "to", "homelab") → "deploy/to/homelab"
Cli.Run uses it for command path resolution.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-20 12:23:05 +00:00
parent e220b9faab
commit c3f457c151
2 changed files with 9 additions and 1 deletions

View file

@ -63,7 +63,7 @@ func (cl *Cli) Run(args ...string) Result[any] {
var remaining []string
for i := len(clean); i > 0; i-- {
path := strings.Join(clean[:i], "/")
path := JoinPath(clean[:i]...)
if c, ok := cl.core.commands.commands[path]; ok {
cmd = c
remaining = clean[i:]

View file

@ -23,6 +23,14 @@ func Print(w io.Writer, format string, args ...any) {
fmt.Fprintf(w, format+"\n", args...)
}
// JoinPath joins string segments into a path with "/" separator.
//
// core.JoinPath("deploy", "to", "homelab") // → "deploy/to/homelab"
// core.JoinPath(args[:3]...) // → first 3 args as path
func JoinPath(segments ...string) string {
return strings.Join(segments, "/")
}
// FilterArgs removes empty strings and Go test runner flags from an argument list.
//
// clean := core.FilterArgs(os.Args[1:])