(state *globalState)
| 93 | } |
| 94 | |
| 95 | func (a *App) metadataInstallCommand(state *globalState) *cobra.Command { |
| 96 | var targets []string |
| 97 | cmd := &cobra.Command{ |
| 98 | Use: "install <install-key>", |
| 99 | Short: "Install a metadata item to one or more target coding agents", |
| 100 | Args: cobra.ExactArgs(1), |
| 101 | RunE: func(cmd *cobra.Command, args []string) error { |
| 102 | out := cmd.OutOrStdout() |
| 103 | store := metadata.NewStore(state.storePath) |
| 104 | svc := metadata.NewService(store) |
| 105 | installKey := args[0] |
| 106 | |
| 107 | if len(targets) == 0 { |
| 108 | targets = []string{"claude"} |
| 109 | } |
| 110 | |
| 111 | // Try each kind until found. |
| 112 | var lastErr error |
| 113 | for _, kind := range []string{"skill", "agent", "instruction", "plugin"} { |
| 114 | err := svc.InstallToTargets(context.Background(), kind, installKey, targets) |
| 115 | if err == nil { |
| 116 | fmt.Fprintf(out, "✓ Installed %s to %s\n", installKey, strings.Join(targets, ", ")) |
| 117 | return nil |
| 118 | } |
| 119 | lastErr = err |
| 120 | } |
| 121 | return fmt.Errorf("install failed: %w", lastErr) |
| 122 | }, |
| 123 | } |
| 124 | cmd.Flags().StringSliceVar(&targets, "target", []string{"claude"}, "Target coding agent(s); repeat or comma-separate (e.g. --target claude,codex)") |
| 125 | return cmd |
| 126 | } |
no test coverage detected