Commit Graph

12 Commits

Author SHA1 Message Date
e835eec6e8 feat(cli): add --force flag to molecule init
Allows re-scaffolding an existing molecule.yaml without manual deletion.
Exit code 1 preserved for existing file without --force (usage error path).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 21:17:36 +00:00
1ebe5fa999 fix(cli): build from module root ("go build .") instead of "./cmd/molecule"
Go 1.25 resolves "./cmd/molecule" relative to cmd.Dir as an absolute path
under the CWD, producing the doubled "cmd/molecule/cmd/molecule" error.
Building the whole module from the root and relying on the binary name
from -o is the idiomatic Go approach and avoids path arithmetic entirely.

Also tightened error message to match the new command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 19:12:49 +00:00
7b254c926c fix(cli): use cwd as repoRoot instead of os.Executable path
os.Executable() in Go 1.x parallel tests resolves to <TempDir>/0/molecule.test
making path-based traversal from the binary back to the repo root unreliable.
Switch to os.Getwd() which always returns the repo checkout root in CI
(where `go test ./cmd/molecule/...` is invoked), and skip any path arithmetic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 19:06:30 +00:00
9dfb5f9aa4 fix(cli): replace runtime.GOEXE with hardcoded "go" in test
runtime.GOEXE is not available in Go 1.25 standard library.
Replace with the standard "go" binary name which is on PATH in CI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 19:03:36 +00:00
6d1bcc007f fix(cli): add missing runtime import to test file
go vet reports: cmd/molecule/molecule_test.go:209:11: undefined: runtime

runtime.GOEXE is used in mol() to find the Go binary for building the
test binary. The runtime package was referenced but not imported.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 19:02:08 +00:00
a1dacff202 fix(cli): remove unused _ = workspaceID, fix repoRoot() path for test binary
- workspace.go: remove no-op _ = workspaceID (workspaceID consumed in runHTTP call)
- molecule_test.go: replace hardcoded /workspace/repos/clone-cli path with
  dynamic exe-based resolution so tests pass when built by CI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 18:35:43 +00:00
1471cad4c1 feat(cli): add molecule completion [bash|zsh|fish|powershell] subcommand
Wires shell completion for all 4 shells via Cobra's built-in generators.
Covers the remaining item from the implementation status checklist.

Adds:
- internal/cmd/completion.go: cobra.GenXxxCompletion wrappers with
  usage examples for each shell
- 5 new integration tests in cmd/molecule/molecule_test.go:
  - TestCLI_Completion_Help (4 shells × help flag)
  - TestCLI_Completion_GeneratesScript (4 shells × script output)
  - TestCLI_Completion_InvalidShell (exit code 2 on bad shell)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 18:06:02 +00:00
47692cfb36 fix(cli): complete "mol" → "molecule" rename in test error messages
All test.Fatalf messages referenced "mol <subcommand>" but the binary
is now "molecule". Also fix configSet to use os.WriteFile atomic write
instead of viper.WriteConfig (avoids file-permission edge cases).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 07:35:31 +00:00
ea69db8bfc fix(cli): complete "mol" → "molecule" rename across all cmd packages
Rename all user-facing "mol" references to "molecule" to match the
published binary name (binary: molecule in .goreleaser.yaml):
- root.go: Use string, versionInfo, viper config name, flag descriptions
- init.go: section comment, Short, Long, cfgPath, scaffolded message
- config.go: Long description, Shorts, configFile, WriteFile, Stat check
- molecule_test.go: binary name, version output check, mol.yaml → molecule.yaml

Also fix test helper to use runtime.GOEXE instead of hardcoded /tmp/go/bin/go.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 06:36:42 +00:00
f654a2dff9 fix(cli): align rootCmd.Use to goreleaser binary name
rootCmd.Use was "mol" while .goreleaser.yaml sets binary: "molecule".
Align to "molecule" to match the published binary name, test
invocations, and docs. Also fix test helper to use runtime.GOEXE
instead of hardcoded /tmp/go/bin/go.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 05:36:07 +00:00
07ab67552a feat(cli): implement mol init + 2 new integration tests
- Add `mol init` command (internal/cmd/init.go): scaffolds mol.yaml
  in the current directory with commented config sections and
  environment variable documentation. Exits with a clear "next steps"
  message. Checks for existing mol.yaml before overwriting.
- Register initCmd in root.go alongside the other command groups.
- Add 2 integration tests: TestCLI_Init (scaffolding + output)
  and TestCLI_Init_AlreadyExists (error path).
- Update CLAUDE.md command reference to list mol init and note it
  is checked off the stub repo checklist.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 10:50:50 +00:00
47b2804516 test(cli): add integration tests and fix CI workflow
- Add 24 integration tests in cmd/molecule/molecule_test.go covering
  all 18 subcommands (workspace, agent, platform, config) including
  error paths for not-found and missing-arg cases
- Tests use httptest mock server; binary built per-test with correct
  repo root for go build ./cmd/molecule
- Fix release.yml: correct binary name (molecule not molecli), correct
  package path (./cmd/molecule not ./cmd/molecli)
- Add test job (go mod tidy + vet + test) to release.yml, runs on
  every PR touching Go files
- Release job gated on test job; conditional on v* tag push
- Mark KI-005 resolved in known-issues.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 10:12:28 +00:00