cli/cmd/forge/helpers.go
Charon c340303314 refactor: flatten commands, extract php/ci to own repos (#2)
## Summary
- Extract PHP/Laravel commands to `core/php` repo (42 files, standalone module)
- Extract CI/release + SDK commands to `core/ci` repo (10 files)
- Remove `internal/variants/` build tag system entirely
- Move all 30 remaining command packages from `internal/cmd/` to top-level `cmd/`
- Rewrite `main.go` with direct imports — no more variant selection
- PHP and CI are now optional via commented import lines in main.go

Co-authored-by: Claude <developers@lethean.io>
Reviewed-on: #2
Co-authored-by: Charon <charon@lthn.ai>
Co-committed-by: Charon <charon@lthn.ai>
2026-02-16 14:45:06 +00:00

33 lines
848 B
Go

package forge
import (
"path"
"strings"
"forge.lthn.ai/core/go/pkg/cli"
)
// splitOwnerRepo splits "owner/repo" into its parts.
func splitOwnerRepo(s string) (string, string, error) {
parts := strings.SplitN(s, "/", 2)
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
return "", "", cli.Err("expected format: owner/repo (got %q)", s)
}
return parts[0], parts[1], nil
}
// strPtr returns a pointer to the given string.
func strPtr(s string) *string { return &s }
// extractRepoName extracts a repository name from a clone URL.
// e.g. "https://github.com/owner/repo.git" -> "repo"
func extractRepoName(cloneURL string) string {
// Get the last path segment
name := path.Base(cloneURL)
// Strip .git suffix
name = strings.TrimSuffix(name, ".git")
if name == "" || name == "." || name == "/" {
return ""
}
return name
}