From ea69db8bfc6b4a01e4fa68cf48976546784ff63a Mon Sep 17 00:00:00 2001 From: Molecule AI SDK-Dev Date: Wed, 22 Apr 2026 06:36:42 +0000 Subject: [PATCH] =?UTF-8?q?fix(cli):=20complete=20"mol"=20=E2=86=92=20"mol?= =?UTF-8?q?ecule"=20rename=20across=20all=20cmd=20packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cmd/molecule/molecule_test.go | 24 ++++++++++++------------ internal/cmd/config.go | 32 ++++++++++++++++---------------- internal/cmd/init.go | 18 +++++++++--------- internal/cmd/root.go | 6 +++--- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/cmd/molecule/molecule_test.go b/cmd/molecule/molecule_test.go index c370feb..241eb7d 100644 --- a/cmd/molecule/molecule_test.go +++ b/cmd/molecule/molecule_test.go @@ -202,7 +202,7 @@ func repoRoot() string { // mol returns the path to the CLI binary, building it if needed. func mol(t *testing.T) string { root := repoRoot() - exe := filepath.Join(t.TempDir(), "mol") + exe := filepath.Join(t.TempDir(), "molecule") goBin := runtime.GOEXE // e.g. "/usr/bin/go" — respects PATH cmd := exec.Command(goBin, "build", "-o", exe, "./cmd/molecule") cmd.Dir = root @@ -269,8 +269,8 @@ func TestCLI_Version(t *testing.T) { t.Fatalf("mol --version: %v", err) } out := stdout.String() - if !strings.Contains(out, "mol") { - t.Errorf("expected 'mol' in version output, got: %s", out) + if !strings.Contains(out, "molecule") { + t.Errorf("expected 'molecule' in version output, got: %s", out) } } @@ -722,9 +722,9 @@ func TestCLI_ConfigInit(t *testing.T) { if err != nil { t.Fatalf("mol config init: %v\nstderr: %s", err, stderr.String()) } - f := filepath.Join(dir, "mol.yaml") + f := filepath.Join(dir, "molecule.yaml") if _, err := os.Stat(f); err != nil { - t.Errorf("mol.yaml not scaffolded at %s", f) + t.Errorf("molecule.yaml not scaffolded at %s", f) } } @@ -762,12 +762,12 @@ func TestCLI_Init(t *testing.T) { if err != nil { t.Fatalf("mol init: %v\nstderr: %s", err, stderr.String()) } - f := filepath.Join(dir, "mol.yaml") + f := filepath.Join(dir, "molecule.yaml") if _, err := os.Stat(f); err != nil { - t.Errorf("mol.yaml not scaffolded at %s", f) + t.Errorf("molecule.yaml not scaffolded at %s", f) } out := stdout.String() - if !strings.Contains(out, "Scaffolded") && !strings.Contains(out, "mol.yaml") { + if !strings.Contains(out, "Scaffolded") && !strings.Contains(out, "molecule.yaml") { t.Errorf("expected scaffolded confirmation in output, got:\n%s", out) } } @@ -775,21 +775,21 @@ func TestCLI_Init(t *testing.T) { func TestCLI_Init_AlreadyExists(t *testing.T) { exe := mol(t) dir := t.TempDir() - // pre-create mol.yaml - os.WriteFile(filepath.Join(dir, "mol.yaml"), []byte("x"), 0o644) + // pre-create molecule.yaml + os.WriteFile(filepath.Join(dir, "molecule.yaml"), []byte("x"), 0o644) cmd := exec.Command(exe, "init") cmd.Dir = dir var stderr bytes.Buffer cmd.Stderr = &stderr err := cmd.Run() if err == nil { - t.Fatalf("expected error when mol.yaml exists, got none") + t.Fatalf("expected error when molecule.yaml exists, got none") } exitErr, ok := err.(*exec.ExitError) if !ok { t.Fatalf("expected *exec.ExitError, got %T", err) } if exitErr.ExitCode() == 0 { - t.Errorf("expected non-zero exit code when mol.yaml exists, got 0") + t.Errorf("expected non-zero exit code when molecule.yaml exists, got 0") } } diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 23edc4b..a05ee24 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -19,11 +19,11 @@ import ( var configCmd = &cobra.Command{ Use: "config", Short: "View and manage CLI and workspace configuration", - Long: `mol config list — list all config keys (from file + env) -mol config get — print a single config value -mol config set — write a key to the config file -mol config init — scaffold a default mol.yaml in the current directory -mol config view — print the current config file with sources annotated`, + Long: `molecule config list — list all config keys (from file + env) +molecule config get — print a single config value +molecule config set — write a key to the config file +molecule config init — scaffold a default molecule.yaml in the current directory +molecule config view — print the current config file with sources annotated`, } func init() { @@ -44,7 +44,7 @@ var configListCmd = &cobra.Command{ func runConfigList(cmd *cobra.Command, _ []string) error { settings := viper.AllSettings() if len(settings) == 0 { - fmt.Println("No config keys set. Use `mol config set ` or set env vars.") + fmt.Println("No config keys set. Use `molecule config set ` or set env vars.") return nil } w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) @@ -85,7 +85,7 @@ func runConfigGet(cmd *cobra.Command, args []string) error { // =========================================================================== var configSetCmd = &cobra.Command{ Use: "set ", - Short: "Write a config key to the config file (~/.config/mol.yaml)", + Short: "Write a config key to the config file (~/.config/molecule.yaml)", Args: cobra.ExactArgs(2), RunE: runConfigSet, } @@ -96,7 +96,7 @@ func runConfigSet(cmd *cobra.Command, args []string) error { if err != nil { configDir = "." } - configFile := filepath.Join(configDir, "mol.yaml") + configFile := filepath.Join(configDir, "molecule.yaml") v := viper.New() v.SetConfigFile(configFile) @@ -116,12 +116,12 @@ func runConfigSet(cmd *cobra.Command, args []string) error { // =========================================================================== var configInitCmd = &cobra.Command{ Use: "init", - Short: "Scaffold a default mol.yaml in the current directory", + Short: "Scaffold a default molecule.yaml in the current directory", RunE: runConfigInit, } func runConfigInit(cmd *cobra.Command, _ []string) error { - const defaultConfig = `# mol CLI config — https://github.com/Molecule-AI/molecule-cli + const defaultConfig = `# molecule CLI config — https://github.com/Molecule-AI/molecule-cli # # All values can be overridden by environment variables: # MOLECULE_API_URL, MOLECULE_RUNTIME_URL, MOL_OUTPUT, MOL_VERBOSE, etc. @@ -135,13 +135,13 @@ func runConfigInit(cmd *cobra.Command, _ []string) error { # Verbose logging: true | false (env: MOL_VERBOSE) # verbose: false ` - if _, err := os.Stat("mol.yaml"); err == nil { - return fmt.Errorf("config init: mol.yaml already exists (not overwriting)") + if _, err := os.Stat("molecule.yaml"); err == nil { + return fmt.Errorf("config init: molecule.yaml already exists (not overwriting)") } - if err := os.WriteFile("mol.yaml", []byte(defaultConfig), 0o644); err != nil { - return fmt.Errorf("config init: write mol.yaml: %w", err) + if err := os.WriteFile("molecule.yaml", []byte(defaultConfig), 0o644); err != nil { + return fmt.Errorf("config init: write molecule.yaml: %w", err) } - fmt.Println("Scaffolded mol.yaml — edit it and run mol --config mol.yaml, or move it to ~/.config/mol.yaml") + fmt.Println("Scaffolded molecule.yaml — edit it and run molecule --config molecule.yaml, or move it to ~/.config/molecule.yaml") return nil } @@ -156,7 +156,7 @@ var configViewCmd = &cobra.Command{ func runConfigView(cmd *cobra.Command, _ []string) error { if viper.ConfigFileUsed() == "" { - fmt.Println("No config file in use. Set one with --config or mol config init.") + fmt.Println("No config file in use. Set one with --config or molecule config init.") fmt.Println("\nActive env vars starting with MOLECULE_ or MOL_:") for _, env := range os.Environ() { if strings.HasPrefix(env, "MOLECULE_") || strings.HasPrefix(env, "MOL_") { diff --git a/internal/cmd/init.go b/internal/cmd/init.go index 9bffdc1..758d4c2 100644 --- a/internal/cmd/init.go +++ b/internal/cmd/init.go @@ -9,13 +9,13 @@ import ( ) // --------------------------------------------------------------------------- -// mol init — bootstrap workspace setup +// molecule init — bootstrap workspace setup // --------------------------------------------------------------------------- var initCmd = &cobra.Command{ Use: "init", - Short: "Bootstrap workspace and scaffold a mol.yaml config file", - Long: `Scaffold a default mol.yaml in the current directory. + Short: "Bootstrap workspace and scaffold a molecule.yaml config file", + Long: `Scaffold a default molecule.yaml in the current directory. This is the primary entry point for new users. Run once in a project to create a configuration file that can be checked into version control. @@ -23,18 +23,18 @@ to create a configuration file that can be checked into version control. All values can be overridden by environment variables (MOLECULE_API_URL, MOLECULE_RUNTIME_URL, etc.). -After init, run 'mol --config mol.yaml workspace list' to verify your setup.`, +After init, run 'molecule --config molecule.yaml workspace list' to verify your setup.`, RunE: runInit, } func runInit(cmd *cobra.Command, _ []string) error { - cfgPath := "mol.yaml" + cfgPath := "molecule.yaml" if _, err := os.Stat(cfgPath); err == nil { return fmt.Errorf("init: %s already exists — not overwriting (use --force to replace)", cfgPath) } - content := `# mol CLI configuration — https://github.com/Molecule-AI/molecule-cli + content := `# molecule CLI configuration — https://github.com/Molecule-AI/molecule-cli # # All values can be overridden by environment variables: # MOLECULE_API_URL, MOLECULE_RUNTIME_URL, MOL_OUTPUT, MOL_VERBOSE, etc. @@ -61,8 +61,8 @@ func runInit(cmd *cobra.Command, _ []string) error { fmt.Printf("Scaffolded %s\n", absPath) fmt.Println() fmt.Println("Next steps:") - fmt.Println(" 1. Edit mol.yaml with your platform URL") - fmt.Println(" 2. Run mol --config mol.yaml workspace list") - fmt.Println(" 3. For full reference: mol --help") + fmt.Println(" 1. Edit molecule.yaml with your platform URL") + fmt.Println(" 2. Run molecule --config molecule.yaml workspace list") + fmt.Println(" 3. For full reference: molecule --help") return nil } diff --git a/internal/cmd/root.go b/internal/cmd/root.go index 714305a..35f04e4 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -50,7 +50,7 @@ func init() { rootCmd.PersistentFlags().StringVarP(&outputFormat, "output", "o", "table", "Output format: table | json | yaml") rootCmd.PersistentFlags().StringVar(&configPath, "config", "", - "Path to config file (default ~/.config/mol.yaml or ./mol.yaml)") + "Path to config file (default ~/.config/molecule.yaml or ./molecule.yaml)") rootCmd.SetFlagErrorFunc(func(cmd *cobra.Command, err error) error { return &exitError{code: 2, msg: err.Error()} }) @@ -63,7 +63,7 @@ func Execute() error { if configPath != "" { viper.SetConfigFile(configPath) } else { - viper.SetConfigName("mol") + viper.SetConfigName("molecule") viper.AddConfigPath("$HOME/.config") viper.AddConfigPath(".") } @@ -123,5 +123,5 @@ func kv(w *tabwriter.Writer, k, v string) { } func versionInfo() string { - return fmt.Sprintf("mol %s (go %s)", Version, runtime.Version()) + return fmt.Sprintf("molecule %s (go %s)", Version, runtime.Version()) } \ No newline at end of file