| 30 | } |
| 31 | |
| 32 | func runPluginInstall(args []string) { |
| 33 | fs := flag.NewFlagSet("plugin install", flag.ContinueOnError) |
| 34 | fs.SetOutput(io.Discard) |
| 35 | homeDir := fs.String("home", "", "Override the home directory used for plugin installation") |
| 36 | pluginPath := fs.String("plugin-path", "", "Override the installed plugin path") |
| 37 | marketplacePath := fs.String("marketplace-path", "", "Override the marketplace manifest path") |
| 38 | if err := fs.Parse(args); err != nil { |
| 39 | if errors.Is(err, flag.ErrHelp) { |
| 40 | fmt.Println("Usage: codemap plugin install [--home <dir>] [--plugin-path <dir>] [--marketplace-path <file>]") |
| 41 | return |
| 42 | } |
| 43 | fmt.Fprintf(os.Stderr, "Error: %v\n", err) |
| 44 | fmt.Fprintln(os.Stderr, "Usage: codemap plugin install [--home <dir>] [--plugin-path <dir>] [--marketplace-path <file>]") |
| 45 | os.Exit(2) |
| 46 | } |
| 47 | if fs.NArg() != 0 { |
| 48 | fmt.Fprintln(os.Stderr, "Usage: codemap plugin install [--home <dir>] [--plugin-path <dir>] [--marketplace-path <file>]") |
| 49 | os.Exit(1) |
| 50 | } |
| 51 | |
| 52 | result, err := pluginbundle.InstallCodemapPlugin(pluginbundle.InstallOptions{ |
| 53 | HomeDir: *homeDir, |
| 54 | PluginPath: *pluginPath, |
| 55 | MarketplacePath: *marketplacePath, |
| 56 | }) |
| 57 | if err != nil { |
| 58 | fmt.Fprintf(os.Stderr, "Plugin install failed: %v\n", err) |
| 59 | os.Exit(1) |
| 60 | } |
| 61 | |
| 62 | absPluginPath, _ := filepath.Abs(result.PluginPath) |
| 63 | absMarketplacePath, _ := filepath.Abs(result.MarketplacePath) |
| 64 | |
| 65 | fmt.Println("codemap plugin install") |
| 66 | fmt.Printf("Plugin: %s\n", absPluginPath) |
| 67 | fmt.Printf("Marketplace: %s\n", absMarketplacePath) |
| 68 | fmt.Printf("Files written: %d\n", result.FilesWritten) |
| 69 | if result.FilesUnchanged > 0 { |
| 70 | fmt.Printf("Files unchanged: %d\n", result.FilesUnchanged) |
| 71 | } |
| 72 | switch { |
| 73 | case result.CreatedMarketplace: |
| 74 | fmt.Println("Marketplace entry: created") |
| 75 | case result.UpdatedMarketplace: |
| 76 | fmt.Println("Marketplace entry: updated") |
| 77 | default: |
| 78 | fmt.Println("Marketplace entry: already configured") |
| 79 | } |
| 80 | fmt.Println() |
| 81 | fmt.Println("Next:") |
| 82 | fmt.Println(" 1. Restart Codex or reload plugins.") |
| 83 | fmt.Println(" 2. Verify the Codemap plugin appears in your plugin list.") |
| 84 | fmt.Println(" 3. If Codemap was installed before this release, update it so `codemap mcp` is available.") |
| 85 | } |