Skip to content

canair update

usage: canair update [-h] [--check] [-y] [--json]

``canair update`` — update the CLI from its git-clone install.

canair is installed from a git clone (``git clone`` + ``uv tool install .``), so
updating means: check out the latest **release tag** in the clone, then reinstall
the tool from it. This command locates that source clone (via uv's tool receipt,
falling back to the package's own repo root), reports the current vs latest
released version with a changelog link, and — after confirmation — runs
``git fetch --tags`` + ``git checkout <tag>`` + ``uv tool install <clone-dir> --reinstall``.

Checking out the advertised release tag (rather than fast-forwarding a branch to
its HEAD) means the installed code is exactly the released version — never
whatever unreleased commits happen to sit on ``main``.

It never mutates anything without an interactive confirmation or ``--yes``, and
degrades gracefully to printing manual instructions when it can't find a git
clone or ``uv`` (e.g. a pip/editable install). ``--check`` reports only;
``--json`` emits a machine-readable summary.

It also reports the **install context**: which copy is running — the repo
working tree (``uv run`` / dev checkout) vs the ``uv tool install`` snapshot
(bare ``canair``) — the clone's current git HEAD (branch name, e.g. ``main``, or
``detached at <tag>`` after an update), and warns when the installed tool copy's
version has drifted out of sync with the source clone's ``pyproject.toml`` (so a
bare ``canair`` would run different code than ``uv run canair``). When there's no
newer release but the installed copy *is* out of sync, ``canair update`` offers a
reinstall-only resync (``uv tool install <clone> --reinstall``) — no network or
tag checkout needed — to bring the bare ``canair`` back in line with the clone.

The reported *current* version is the provenance-bearing one
(:func:`canlib.build_info.full_version`) — from a checkout it names the branch and
commit — while the release comparison runs on the pure package version.

Because a reinstall replaces the installed package directory wholesale, it also
deletes anything written into that copy's bundled profiles (a bare
``canair … --save`` lands there). Before either reinstall path asks for
confirmation, the profile data that exists only in the snapshot is listed, so it
can be rescued instead of silently discarded.

options:
  -h, --help  show this help message and exit
  --check     Only report the current/latest version and changelog; make no
              changes
  -y, --yes   Skip the confirmation prompt (checkout release tag + reinstall)
  --json      Emit machine-readable JSON

examples:
  canair update            # check, confirm, then checkout release tag + reinstall
  canair update --check    # report current/latest + changelog, change nothing
  canair update --yes      # update without the confirmation prompt (automation)
  canair update --json     # machine-readable version/clone summary