Skip to content

Commit 52b9941

Browse files
refactor: deprecate 'self-update' in favor of 'self update'
Consolidates two self-update commands into one canonical version. CHANGES: - Added --dry-run flag to 'shells self update' command - Deprecated 'shells self-update' (hyphenated) command - Added deprecation warnings when using old command - Hidden old command from help output MIGRATION PATH: - Old: shells self-update [--dry-run] - New: shells self update [--dry-run] [--branch] [--source] etc. The new 'shells self update' command provides: - Better backup management (configurable max backups) - Automatic binary validation - Multiple configuration options - Automatic database migrations - More robust error handling via pkg/self updater The old command still works but shows deprecation warnings. DEPRECATION NOTICE: Command: shells self-update Status: Hidden, deprecated Replacement: shells self update Will be removed in: Future version Users should update scripts and documentation to use the new command. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3d599f9 commit 52b9941

2 files changed

Lines changed: 39 additions & 15 deletions

File tree

cmd/self.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var (
3939
updateSkipBackup bool
4040
updateSkipValidate bool
4141
updateSourceDir string
42+
updateDryRun bool
4243
)
4344

4445
func init() {
@@ -47,6 +48,7 @@ func init() {
4748
updateCmd.Flags().BoolVar(&updateSkipBackup, "skip-backup", false, "Skip backing up current binary")
4849
updateCmd.Flags().BoolVar(&updateSkipValidate, "skip-validation", false, "Skip validating new binary (not recommended)")
4950
updateCmd.Flags().StringVar(&updateSourceDir, "source", "/opt/shells", "Path to shells git repository")
51+
updateCmd.Flags().BoolVar(&updateDryRun, "dry-run", false, "Check for updates without installing")
5052

5153
// Add subcommands
5254
selfCmd.AddCommand(updateCmd)
@@ -69,6 +71,7 @@ func runUpdate(cmd *cobra.Command, args []string) error {
6971
logger.Infow("Starting Shells self-update",
7072
"branch", updateBranch,
7173
"source_dir", updateSourceDir,
74+
"dry_run", updateDryRun,
7275
)
7376

7477
// Create updater configuration
@@ -85,6 +88,27 @@ func runUpdate(cmd *cobra.Command, args []string) error {
8588
// Create updater
8689
updater := self.NewShellsUpdater(logger, updateConfig)
8790

91+
// Dry run: just assess and report
92+
if updateDryRun {
93+
logger.Infow("Dry-run mode: assessing update availability")
94+
state, err := updater.Assess()
95+
if err != nil {
96+
return fmt.Errorf("assessment failed: %w", err)
97+
}
98+
99+
fmt.Println()
100+
fmt.Println("Dry-run Assessment:")
101+
fmt.Println("===================")
102+
fmt.Printf("Source directory: %s (exists: %v)\n", updateSourceDir, state.SourceExists)
103+
fmt.Printf("Git repository: %v\n", state.GitRepository)
104+
fmt.Printf("Current version: %s\n", state.CurrentVersion)
105+
fmt.Printf("Binary path: %s (exists: %v)\n", updateConfig.BinaryPath, state.BinaryExists)
106+
fmt.Printf("Backup count: %d\n", len(state.BackupPaths))
107+
fmt.Println()
108+
fmt.Println("Run without --dry-run to perform the actual update")
109+
return nil
110+
}
111+
88112
// Execute update
89113
if err := updater.Update(); err != nil {
90114
logger.Errorw("Self-update failed", "error", err)

cmd/self_update.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,11 @@ var (
2121
)
2222

2323
var selfUpdateCmd = &cobra.Command{
24-
Use: "self-update",
25-
Short: "Update shells to the latest version from GitHub",
26-
Long: `Update shells to the latest version by pulling from the GitHub repository,
27-
rebuilding the binary, and verifying the update with SHA256 checksums.
28-
29-
This command will:
30-
1. Pull the latest code from the GitHub repository
31-
2. Run ./install.sh to rebuild and install the binary
32-
3. Compare SHA256 hashes to verify the update
33-
4. Report the size of the new binary
34-
35-
The binary is always rebuilt after pulling to ensure you have the latest version,
36-
even if no new commits were pulled.
37-
38-
Use --dry-run to preview the update without installing.`,
24+
Use: "self-update",
25+
Short: "DEPRECATED: Use 'shells self update' instead",
26+
Long: `DEPRECATED: This command is deprecated and will be removed in a future version.`,
27+
Deprecated: "Use 'shells self update' instead, which provides better error handling, backup management, and database migrations.",
28+
Hidden: true,
3929
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
4030
// Initialize config but skip database for self-update
4131
return initConfig()
@@ -49,6 +39,16 @@ func init() {
4939
}
5040

5141
func runSelfUpdate(cmd *cobra.Command, args []string) error {
42+
fmt.Println()
43+
fmt.Println("⚠️ WARNING: This command is DEPRECATED")
44+
fmt.Println(" Use 'shells self update' instead for:")
45+
fmt.Println(" - Better backup management")
46+
fmt.Println(" - Automatic database migrations")
47+
fmt.Println(" - Improved error handling")
48+
fmt.Println()
49+
fmt.Println("Continuing with deprecated command...")
50+
fmt.Println()
51+
5252
log.Info("🔄 Starting shells self-update...", "component", "self_update")
5353

5454
// Get current binary path

0 commit comments

Comments
 (0)