sbg

Crates.iosbg
lib.rssbg
version0.0.3
sourcesrc
created_at2018-10-11 20:55:58.330457
updated_at2022-08-14 22:53:44.622246
descriptiongenerates CLI boilerplate
homepage
repositoryhttps://github.com/tshepang/sbg
max_upload_size
id89341
size37,159
Tshepang Mbambo (tshepang)

documentation

README

sbg - CLI Boilerplate Generator

build status

The s in sbg was for StructOpt, but that is now deprecated, but I would like to keep the name for now.

You give this a yaml spec and it generates boilerplate code for you, which compiles if you give it Cargo.toml with these contents:

[dependencies]
anyhow = "1"
url = "2"

[dependencies.clap]
version = "3"
features = ["derive"]

This is not flexible, and only supports a tiny subset of what clap supports.

The first time steved mentioned the idea to me, I felt "meh!", but once you get to nested subcommands, it becomes unwieldy the code you gotta write to handle that. He even went as far as writing the code (not public), but unsatisfied by the notation, I wrote this implementation. My actual inspiration though is I wanted something that'd also generate warp boilerplate, together with the reqwest code which generates it (which also exists, but is also not public).

Would be nice to fix

  • check "type" actually has valid Rust types
  • check "name" does not have spaces
  • disallow having both "args" and "nested" (results in build failure), or support it (which would be useful for subcommands that share some options)
  • when "type" is not specified, assume bool
  • ensure no args have same name (results in build failure)
  • support > 1 positional args

Installation

Assuming you have the Rust toolchain installed:

cargo install sbg

NOTE: minimum required rustc is v1.58, due to serde-yaml requiring it.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 84

cargo fmt