From a681bb881c5ee7ba3c07f752b5f42a3ded87ce22 Mon Sep 17 00:00:00 2001 From: Bear Date: Mon, 9 Mar 2026 15:20:28 -0600 Subject: [PATCH] fix: replace --dry-run flag with --confirm for prune-archived The --dry-run boolean flag (default true) was unusable because Cobra boolean flags require --flag=false syntax (with =), and --flag false (with space) silently ignores the value. Replace with a --confirm flag (default false) so dry-run is the implicit default and users opt in to deletion with --confirm. --- cmd/prune_archived.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/prune_archived.go b/cmd/prune_archived.go index 2fd591e..f57e6a4 100644 --- a/cmd/prune_archived.go +++ b/cmd/prune_archived.go @@ -11,9 +11,9 @@ import ( ) var ( - pruneOrg string - prunePath string - dryRun bool + pruneOrg string + prunePath string + pruneConfirm bool ) var pruneArchivedCmd = &cobra.Command{ @@ -23,8 +23,8 @@ var pruneArchivedCmd = &cobra.Command{ Any directory that corresponds to an archived repository in the specified organization will be removed. -By default runs in dry-run mode (--dry-run) so you can preview what would be deleted. -Pass --dry-run=false to actually remove directories.`, +By default runs in dry-run mode so you can preview what would be deleted. +Pass --confirm to actually remove directories.`, RunE: func(cmd *cobra.Command, args []string) error { return runPruneArchived(cmd.Context()) }, @@ -34,7 +34,7 @@ Pass --dry-run=false to actually remove directories.`, func init() { pruneArchivedCmd.Flags().StringVarP(&pruneOrg, "org", "o", "", "GitHub organization to check repositories against (required)") pruneArchivedCmd.Flags().StringVarP(&prunePath, "path", "p", "", "Local path containing cloned repositories (required)") - pruneArchivedCmd.Flags().BoolVar(&dryRun, "dry-run", true, "Preview what would be removed without deleting anything") + pruneArchivedCmd.Flags().BoolVar(&pruneConfirm, "confirm", false, "Actually remove directories (without this flag, runs in dry-run mode)") _ = pruneArchivedCmd.MarkFlagRequired("org") _ = pruneArchivedCmd.MarkFlagRequired("path") @@ -87,7 +87,7 @@ func runPruneArchived(ctx context.Context) error { dirPath := filepath.Join(absPath, name) - if dryRun { + if !pruneConfirm { fmt.Printf("[dry-run] would remove: %s\n", dirPath) removedCount++ continue @@ -102,10 +102,10 @@ func runPruneArchived(ctx context.Context) error { removedCount++ } - if dryRun { + if !pruneConfirm { fmt.Printf("\nDry-run complete: %d archived repositories would be removed\n", removedCount) if removedCount > 0 { - fmt.Println("Run with --dry-run=false to actually remove them") + fmt.Println("To actually remove them, re-run with the --confirm flag") } } else { fmt.Printf("\nSummary: Removed %d archived repositories", removedCount)