# gram update

The `update` command updates the gram CLI to the latest available version. It automatically detects the installation method (Homebrew, Aqua, or manual) and uses the appropriate update mechanism.

<Callout type="info">
    The `gram update` command supports multiple installation methods and will automatically use the right one based on how the CLI was originally installed.
</Callout>

## Usage

Update to the latest version:

```bash
gram update
```

Check for updates without installing:

```bash
gram update --check
```

Force update even if already on the latest version:

```bash
gram update --force
```

## How it works

The update command:

1. Checks the current version of the gram CLI
2. Fetches the latest release information from GitHub
3. Compares versions to determine if an update is available
4. Detects the installation method (Homebrew, Aqua, or manual)
5. Uses the appropriate update mechanism for that installation

### Installation methods

**Homebrew (macOS/Linux):**
- Automatically runs `brew upgrade speakeasy-api/tap/gram`
- Recommended for most users on macOS and Linux

**Aqua:**
- Automatically runs `aqua upgrade speakeasy-api/gram/gram`
- Used when the CLI was installed via the Aqua package manager

**Manual installation:**
- Downloads the latest binary from GitHub releases
- Replaces the current binary with the new version
- Creates a backup of the old binary during the update process

## Options

### <code>--check</code>

Check for updates without installing them. This is useful for scripting or to see if an update is available.

```bash
gram update --check
```

Aliases: `-c`

### <code>--force</code>

Force an update even if the CLI is already on the latest version. This can be useful when reinstalling the current version.

```bash
gram update --force
```

## Examples

Check if an update is available:

```bash
$ gram update --check
→ Update available: 0.9.12 → 0.9.13
```

Update to the latest version:

```bash
$ gram update
📦 Updating manually to version 0.9.13...
✓ Successfully updated gram CLI to version 0.9.13
  Run 'gram --version' to verify the new version
```

Update via Homebrew:

```bash
$ gram update
🍺 Updating via Homebrew...
✓ Successfully updated gram CLI via Homebrew
  Run 'gram --version' to verify the new version
```

## Notes

<Callout type="warning">
    Development builds (version "dev") cannot be updated using this command. Rebuild from source or install a released version instead.
</Callout>

- The update command requires internet access to check for and download new versions
- For manual installations, the command creates a backup of the current binary before updating
- Updates are fetched from the official GitHub releases of the `speakeasy-api/gram` repository
