[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find ONE feature ... #28

Merged
Virgil merged 1 commit from agent/read---spec-code-core-go-cli-rfc-md-full into dev 2026-04-02 03:36:56 +00:00
3 changed files with 86 additions and 8 deletions
Showing only changes of commit 32342dfd31 - Show all commits

View file

@ -25,7 +25,7 @@ var (
// addPkgInstallCommand adds the 'pkg install' command.
func addPkgInstallCommand(parent *cobra.Command) {
installCmd := &cobra.Command{
Use: "install <org/repo>",
Use: "install [org/]repo",
Short: i18n.T("cmd.pkg.install.short"),
Long: i18n.T("cmd.pkg.install.long"),
RunE: func(cmd *cobra.Command, args []string) error {
@ -45,12 +45,18 @@ func addPkgInstallCommand(parent *cobra.Command) {
func runPkgInstall(repoArg, targetDir string, addToRegistry bool) error {
ctx := context.Background()
// Parse org/repo
parts := strings.Split(repoArg, "/")
if len(parts) != 2 {
return errors.New(i18n.T("cmd.pkg.error.invalid_repo_format"))
// Parse repo shorthand:
// - repoName -> defaults to host-uk/repoName
// - org/repo -> uses the explicit org
org := "host-uk"
repoName := repoArg
if strings.Contains(repoArg, "/") {
parts := strings.Split(repoArg, "/")
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
return errors.New(i18n.T("cmd.pkg.error.invalid_repo_format"))
}
org, repoName = parts[0], parts[1]
}
org, repoName := parts[0], parts[1]
// Determine target directory
if targetDir == "" {

View file

@ -0,0 +1,69 @@
package pkgcmd
import (
"context"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRunPkgInstall_AllowsRepoShorthand_Good(t *testing.T) {
tmp := t.TempDir()
targetDir := filepath.Join(tmp, "packages")
originalGitClone := gitClone
t.Cleanup(func() {
gitClone = originalGitClone
})
var gotOrg, gotRepo, gotPath string
gitClone = func(_ context.Context, org, repoName, repoPath string) error {
gotOrg = org
gotRepo = repoName
gotPath = repoPath
return nil
}
err := runPkgInstall("core-api", targetDir, false)
require.NoError(t, err)
assert.Equal(t, "host-uk", gotOrg)
assert.Equal(t, "core-api", gotRepo)
assert.Equal(t, filepath.Join(targetDir, "core-api"), gotPath)
_, err = os.Stat(targetDir)
require.NoError(t, err)
}
func TestRunPkgInstall_AllowsExplicitOrgRepo_Good(t *testing.T) {
tmp := t.TempDir()
targetDir := filepath.Join(tmp, "packages")
originalGitClone := gitClone
t.Cleanup(func() {
gitClone = originalGitClone
})
var gotOrg, gotRepo, gotPath string
gitClone = func(_ context.Context, org, repoName, repoPath string) error {
gotOrg = org
gotRepo = repoName
gotPath = repoPath
return nil
}
err := runPkgInstall("myorg/core-api", targetDir, false)
require.NoError(t, err)
assert.Equal(t, "myorg", gotOrg)
assert.Equal(t, "core-api", gotRepo)
assert.Equal(t, filepath.Join(targetDir, "core-api"), gotPath)
}
func TestRunPkgInstall_InvalidRepoFormat_Bad(t *testing.T) {
err := runPkgInstall("a/b/c", t.TempDir(), false)
require.Error(t, err)
assert.Contains(t, err.Error(), "invalid repo format")
}

View file

@ -60,10 +60,10 @@ core pkg search --refresh
## pkg install
Clone a package from GitHub.
Clone a package from GitHub. If you pass only a repo name, `core` assumes the `host-uk` org.
```bash
core pkg install <org/repo> [flags]
core pkg install [org/]repo [flags]
```
### Flags
@ -76,6 +76,9 @@ core pkg install <org/repo> [flags]
### Examples
```bash
# Clone from the default host-uk org
core pkg install core-api
# Clone to packages/
core pkg install host-uk/core-php