From c3f457c151fb34d112c4698da0bc855ae5d21fcb Mon Sep 17 00:00:00 2001 From: Snider Date: Fri, 20 Mar 2026 12:23:05 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20JoinPath=20helper=20=E2=80=94=20joins?= =?UTF-8?q?=20segments=20with=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit core.JoinPath("deploy", "to", "homelab") → "deploy/to/homelab" Cli.Run uses it for command path resolution. Co-Authored-By: Virgil --- pkg/core/cli.go | 2 +- pkg/core/utils.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/core/cli.go b/pkg/core/cli.go index a4535d8..be8c91e 100644 --- a/pkg/core/cli.go +++ b/pkg/core/cli.go @@ -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:] diff --git a/pkg/core/utils.go b/pkg/core/utils.go index 6c5d383..7fa5d81 100644 --- a/pkg/core/utils.go +++ b/pkg/core/utils.go @@ -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:])