Skip to main content

Module cli_update

Module cli_update 

Source
Expand description

Update notice and self-update for the family’s command-line tools, from GitHub releases.

Each tool’s CLI used to carry its own copy of this, and the copies had drifted apart. What they share:

  • The notice is cheap, and it can be turned off. A command may ask GitHub for the latest release at most once a day. The answer is cached, so the other runs of the day make no network request and wait for nothing. No check is made when the user turns it off (UpdateCheck::start’s disabled, wired to a --no-update-check flag, or the <TOOL>_NO_UPDATE_CHECK / UNPARSER_NO_UPDATE_CHECK environment variables), in CI (CI is set), or when stderr, where the notice is printed, is not a terminal.
  • The update installs the tool’s own archive. A release carries the CLI archive <bin>-<os>-<arch>-v<version>.<ext> and the C library archive lib<bin>-…, whose name contains the CLI’s. Asset names are therefore compared for equality, never by substring.

Structs§

Tool
The tool an update is for.
UpdateCheck
A run’s update check: started when the command starts, finished when it ends.

Enums§

Skip
Why no check is made, if one is not.

Constants§

FAMILY_OPT_OUT_VARIABLE
The variable that turns the notice off for every tool of the family.

Functions§

run_update
The update command: report the latest release and, unless check_only, replace the running executable with it. force reinstalls even when up to date. A cargo install is pointed at cargo install instead.
skip_reason
Whether a run should look for an update, given its environment. env reads a variable, stderr_is_terminal says where the notice would go.