Skip to main content

upgrade

Upgrade Haft CLI to the latest version.

Usage

haft upgrade [flags]

Description

The haft upgrade command provides a safe and convenient way to update your Haft installation to the latest version. It automatically:

  1. Checks if a newer version is available
  2. Downloads the latest release for your platform
  3. Verifies download integrity using SHA256 checksums
  4. Creates a backup of your current installation
  5. Installs the new version
  6. Verifies the installation works correctly
  7. Automatically rolls back if anything fails

Flags

FlagShortDescription
--check-cOnly check for updates without installing
--force-fForce upgrade even if already on latest version
--version-vUpgrade to a specific version
--jsonOutput result as JSON

Examples

Check and upgrade to latest version

haft upgrade

Output:

INFO  Checking for updates...
INFO Current version version=v0.4.2
INFO Latest version version=v0.5.0
INFO Platform os=linux arch=amd64
INFO Downloading version=v0.5.0
INFO Extracting binary...
INFO Installing new version...
INFO Verifying installation...
SUCCESS Successfully upgraded from v0.4.2 to v0.5.0

Check for updates without installing

haft upgrade --check

Output:

INFO  Checking for updates...
INFO Current version version=v0.4.2
INFO Latest version version=v0.5.0
SUCCESS Update available! Run 'haft upgrade' to install.

Force reinstall

haft upgrade --force

Useful when you want to reinstall the current version (e.g., if the binary is corrupted).

Upgrade to specific version

haft upgrade --version v0.4.0

JSON output for scripting

haft upgrade --check --json

Output:

{
"current_version": "v0.4.2",
"latest_version": "v0.5.0",
"update_available": true,
"upgraded": false,
"platform": {
"os": "linux",
"arch": "amd64"
}
}

Platform Support

The upgrade command supports the following platforms:

PlatformArchitecture
Linuxamd64, arm64
macOSamd64 (Intel), arm64 (Apple Silicon)
Windowsamd64

Safety Features

Automatic Backup

Before upgrading, Haft creates a backup of your current installation. If anything goes wrong during the upgrade, your original version is automatically restored.

Checksum Verification

Downloaded files are verified against SHA256 checksums published with each release to ensure download integrity.

Installation Verification

After installation, Haft runs a verification check to ensure the new binary works correctly. If verification fails, the backup is automatically restored.

Multiple Installation Support

If Haft is installed in multiple locations (e.g., /usr/local/bin and ~/.local/bin), the upgrade command will update all installations.

Error Handling

ScenarioBehavior
No internet connectionShows error message
Already on latest versionShows "already up to date" message
Download failsShows error, no changes made
Checksum mismatchShows error, no changes made
Installation failsAutomatically restores backup
Verification failsAutomatically restores backup

Exit Codes

CodeMeaning
0Success (upgraded or already up to date)
1Error occurred

See Also