car·go·lin·er, noun:
- a cargo ship that sails regularly between designated ports according to a published schedule.
Summary
cargo install works very well to download, compile and install a binary
package. However, it does not offer means to update currently installed
programs without having to specify them manually one by one on the CLI. That
becomes quickly bothersome when having to maintain several packages up-to-date,
especially if it needs to be done on multiple workstations.
Some projects, such as cargo-update or cargo-updater, exist in order to
solve this issue. Their strategy is to exploit the $CARGO_HOME/.crates.toml
and $CARGO_HOME/.crates2.json files that Cargo generates and maintains in
order to track which packages are installed, their exact version, where they
were downloaded from and which programs they have installed. This strategy is
quite effective, so if you are looking for exactly that, then check them out.
However, some problems are still not solved like this: when configuring a new workstation, there is still the need to specify each package manually at least once; when adding a new package on one already-configured workstation, there is still the need to install it manually on all others. These tools lack sharing and synchronisation.
The current project therefore inspires itself from tools such as zplug for
Zsh and vim-plug for Vim by taking orders from a central configuration file.
The tool then simply runs cargo install for all packages listed in that file.
That enables one to install and maintain all packages up-to-date, but also to
keep all of one's workstations synchronised by sharing the file between them in
some way, using Git for example.
Installation
-
Run:
cargo install cargo-liner. -
Create the configuration file to be located at:
$CARGO_HOME/liner.toml.- See the reference documentation about Cargo Home if you have trouble locating the directory.
-
Populate the file with packages you wish to be installed, for example :
[] = "*" = "~0.22" = "0.71.0"
Usage
CLI
As of now, the CLI is virtually non-existent:
Simply run cargo liner in order to:
- Read packages from the configuration file.
- Run
cargo installfor each of them.
Configuration
The file must be located at $CARGO_HOME/liner.toml and contain a
properly-formed TOML document respecting the following format:
[]
= "version-req-1"
= "version-req-2"
#...
where:
package-name-*must be a valid package name, i.e. match[a-zA-Z][a-zA-Z0-9_-]*or something like that.version-req-*must be a valid SemVer requirement, Cargo style. In particular, the catch-all wildcard*can be used to require the latest version available.