Crates.io | package-bootstrap |
lib.rs | package-bootstrap |
version | 0.4.0 |
source | src |
created_at | 2023-03-27 19:22:31.312514 |
updated_at | 2024-01-19 23:21:22.012614 |
description | An embeddable solution for installing build artifacts |
homepage | |
repository | https://codeberg.org/jeang3nie/package-bootstrap |
max_upload_size | |
id | 822397 |
size | 17,426 |
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.
# 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")
}