simple_dynamic/
simple_dynamic.rs1#![allow(dead_code)]
4use bpaf::*;
5
6fn crates(input: &String) -> Vec<(&'static str, Option<&'static str>)> {
7 let crates = [
8 (
9 "cargo-hackerman",
10 "Workspace hack management and package/feature query",
11 ),
12 ("cargo-prebuilt", "Download prebuilt crate binaries"),
13 ("cargo-show-asm", "Display generated assembly"),
14 (
15 "cargo-supply-chain",
16 "Gather author, contributor, publisher data on crates",
17 ),
18 ("chezmoi_modify_manager", "Chezmoi addon to patch ini files"),
19 ("xvf", "Easy archive extraction"),
20 ("newdoc", "Generate pre-populated module files"),
21 (
22 "nust64",
23 "Tools for compiling a Rust project into an N64 ROM",
24 ),
25 ("uggo", "CLI tool to query builds from u.gg"),
26 ];
27
28 crates
29 .iter()
30 .filter(|p| p.0.starts_with(input))
31 .map(|name| (name.0, Some(name.1)))
32 .collect::<Vec<_>>()
33}
34
35#[derive(Debug, Clone, Copy, Bpaf)]
36#[bpaf(fallback(Format::Text))]
38enum Format {
39 Json,
41 Xml,
43 Text,
45}
46
47#[derive(Debug, Clone, Bpaf)]
48#[bpaf(options)]
49pub struct Options {
50 #[bpaf(long("crate"), argument("NAME"), complete(crates))]
52 name: String,
53 dependencies: bool,
55 #[bpaf(external)]
56 format: Format,
57 #[bpaf(positional("URL"))]
59 upload: Option<String>,
60}
61
62fn main() {
63 println!("{:?}", options().run());
64}