9 unstable releases (3 breaking)
0.4.0 | Jan 19, 2024 |
---|---|
0.3.2 | Jun 2, 2023 |
0.3.0 | May 7, 2023 |
0.2.1 | May 5, 2023 |
0.1.2 | Mar 30, 2023 |
#311 in Build Utils
50 downloads per month
Used in gfret
18KB
272 lines
Contents
About
Package bootstrap is an embeddable installer for Rust binaries that allows the reuse of the code in your project to generate shell completions, manpages and other artifacts and install them into directories appropriate for a Unix system.
Usage
# Cargo.toml
[[bin]]
name = "bootstrap"
path = "src/bootstrap.rs
[dependencies.package_bootstrap]
version = "0.1"
features = ["complete", "mangen"]
// bootstrap.rs
use clap::Command;
use package_bootstrap::Bootstrap;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let cmd = Command::new("foo")
.about("manage all of your bars");
let bootstrap = Bootstrap::new("foo", cmd);
bootstrap.install(Path::new("pkg/usr", 1)?;
}
With a little extra setup, bootstrap can use the same function as your binary to
generate the clap::Command
struct.
# Cargo.toml
[workspace]
members = "cli"
[workspace.dependencies]
clap = 4.1
cli = { path = "cli" }
// cli/src/lib.rs
pub fn cli() -> clap::Command {
Command::new("foo")
.about("Handle all of your bars")
}
Features
- default: complete - generates and installs shell completions from your clap::Command struct
- mangen: - generates and installs a Unix manual page from your clap::Command struct
Supported shells:
- bash
- elvish
- fish
- nushell
- powershell
- zsh
Dependencies
~0–0.8MB
~17K SLoC