============================================================================ update — fetch/update from configured repositories ============================================================================
(kind entities.Kind)
| 1151 | // ============================================================================ |
| 1152 | |
| 1153 | func entityUpdateCommand(kind entities.Kind) *cobra.Command { |
| 1154 | var ( |
| 1155 | owner string |
| 1156 | repo string |
| 1157 | branch string |
| 1158 | path string |
| 1159 | all bool |
| 1160 | force bool |
| 1161 | dryRun bool |
| 1162 | ) |
| 1163 | cmd := &cobra.Command{ |
| 1164 | Use: "update", |
| 1165 | Short: "Fetch/update " + string(kind) + "s from configured repositories", |
| 1166 | Long: "Fetch " + string(kind) + `s from GitHub repositories and update the local store. |
| 1167 | |
| 1168 | By default, fetches from all configured repositories (bundled defaults, |
| 1169 | local repo configs, and remote sources from config.yaml). |
| 1170 | |
| 1171 | Use --owner/--repo to fetch from a single specific repository instead. |
| 1172 | Use --all to update without prompting (non-interactive mode). |
| 1173 | Use --force to re-download even if already up to date. |
| 1174 | Use --dry-run to check for updates without modifying files.`, |
| 1175 | Example: " cam " + string(kind) + " update\n" + |
| 1176 | " cam " + string(kind) + " update --owner anthropics --repo skills\n" + |
| 1177 | " cam " + string(kind) + " update --all\n" + |
| 1178 | " cam " + string(kind) + " update --dry-run", |
| 1179 | Args: cobra.NoArgs, |
| 1180 | RunE: func(cmd *cobra.Command, args []string) error { |
| 1181 | out := cmd.OutOrStdout() |
| 1182 | |
| 1183 | if dryRun { |
| 1184 | fmt.Fprintf(out, "[dry-run] Checking %s repositories...\n\n", kind) |
| 1185 | } |
| 1186 | |
| 1187 | if owner != "" && repo != "" { |
| 1188 | if dryRun { |
| 1189 | fmt.Fprintf(out, "[dry-run] Would fetch from %s/%s@%s\n", owner, repo, branch) |
| 1190 | return nil |
| 1191 | } |
| 1192 | return fetchSingleRepo(kind, owner, repo, branch, path, out) |
| 1193 | } |
| 1194 | |
| 1195 | if dryRun { |
| 1196 | return dryRunAllRepos(kind, out) |
| 1197 | } |
| 1198 | |
| 1199 | return fetchAllRepos(cmd, kind, out) |
| 1200 | }, |
| 1201 | } |
| 1202 | cmd.Flags().StringVarP(&owner, "owner", "o", "", "GitHub owner (for single-repo fetch)") |
| 1203 | cmd.Flags().StringVarP(&repo, "repo", "r", "", "GitHub repo (for single-repo fetch)") |
| 1204 | cmd.Flags().StringVarP(&branch, "branch", "b", "main", "Branch") |
| 1205 | cmd.Flags().StringVarP(&path, "path", "p", "", "Sub-directory within the repo") |
| 1206 | cmd.Flags().BoolVar(&all, "all", false, "Update all without prompting") |
| 1207 | cmd.Flags().BoolVar(&force, "force", false, "Re-download even if already up to date") |
| 1208 | cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Report available updates without modifying files") |
| 1209 | return cmd |
| 1210 | } |
no test coverage detected