update

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 14 Imported by: 0

README

Update Command

The update command allows you to update installed commands to their latest versions.

Usage

Update a single command
ccmd update <command-name>
Update all installed commands
ccmd update --all

Features

  • Version comparison using semantic versioning
  • Support for both tagged releases and commit hashes
  • Dual structure maintenance (directory and .md file)
  • Progress indicators with spinners
  • Comprehensive error handling and rollback
  • Batch updates with summary report

Implementation Details

The update command:

  1. Checks if a command is installed
  2. Clones the repository to check for latest version
  3. Compares current version with latest available
  4. Performs update if newer version is available
  5. Updates both directory structure and standalone .md file
  6. Updates the lock file with new version and timestamp
Version Comparison Logic
  • Semantic versions are compared properly (e.g., v1.0.0 < v1.1.0)
  • Tagged versions are preferred over commit hashes
  • If both versions are commits, they are considered different but not comparable

Testing

The command includes comprehensive tests covering:

  • Version comparison logic
  • Single command updates
  • Batch updates with --all flag
  • Error handling scenarios

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCommandNameRequired is returned when no command name is provided and --all is not set.
	ErrCommandNameRequired = errors.New("command name required (or use --all to update all commands)")
	// ErrCannotSpecifyWithAll is returned when a command name is provided with --all flag.
	ErrCannotSpecifyWithAll = errors.New("cannot specify command name with --all flag")
	// ErrSomeUpdatesFailed is returned when some updates fail in batch update.
	ErrSomeUpdatesFailed = errors.New("some updates failed")
)

Functions

func NewCommand

func NewCommand() *cobra.Command

NewCommand creates a new update command.

Types

type Result

type Result struct {
	Error          error
	Name           string
	CurrentVersion string
	NewVersion     string
	Updated        bool
}

Result represents the result of an update operation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL