#installer #shell-completion #command-line #build-tool

build package-bootstrap

用于安装构建工件的内嵌解决方案

9 个不稳定版本 (3 个破坏性更新)

0.4.0 2024年1月19日
0.3.2 2023年6月2日
0.3.0 2023年5月7日
0.2.1 2023年5月5日
0.1.2 2023年3月30日

#168 in 构建工具

每月50次下载
用于 gfret

GPL-3.0-only

18KB
272

内容

关于

Package bootstrap 是一个可内嵌的 Rust 二进制安装程序,允许您重用项目中的代码来生成 shell 补全、man 页面和其他工件,并将它们安装到 Unix 系统合适的目录中。

用法

# 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)?;
}

经过一点额外的配置,bootstrap 可以使用与您的二进制文件相同的函数来生成 clap::Command 结构体。

# 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")
}

功能

  • 默认:complete - 从您的 clap::Command 结构体生成和安装 shell 补全
  • mangen: - 从您的 clap::Command 结构体生成和安装 Unix 手册页

支持的 shell

  • bash
  • elvish
  • fish
  • nushell
  • powershell
  • zsh

依赖

~0–0.8MB
~16K SLoC