diff --git a/uniffi_bindgen/Cargo.toml b/uniffi_bindgen/Cargo.toml index b56198908c..0cd71ff531 100644 --- a/uniffi_bindgen/Cargo.toml +++ b/uniffi_bindgen/Cargo.toml @@ -19,7 +19,7 @@ anyhow = "1" askama = { version = "0.11", default-features = false, features = ["config"] } cargo_metadata = "0.14" camino = "1.0.8" -clap = { version = "3.1", features = ["cargo", "std", "derive"] } +clap = { version = "~3.1", features = ["cargo", "std", "derive"] } fs-err = "2.7.0" heck = "0.4" paste = "1.0" diff --git a/uniffi_bindgen/src/lib.rs b/uniffi_bindgen/src/lib.rs index d0bd4c15f7..3d7bd9b46e 100644 --- a/uniffi_bindgen/src/lib.rs +++ b/uniffi_bindgen/src/lib.rs @@ -469,11 +469,12 @@ impl MergeWith for HashMap { } } -// structs to help our cmdline parsing. +// structs to help our cmdline parsing. Note that docstrings below form part +// of the "help" output. +/// Scaffolding and bindings generator for Rust #[derive(Parser)] #[clap(name = "uniffi-bindgen")] #[clap(version = clap::crate_version!())] -#[clap(about = "Scaffolding and bindings generator for Rust")] #[clap(propagate_version = true)] struct Cli { #[clap(subcommand)] @@ -482,77 +483,59 @@ struct Cli { #[derive(Subcommand)] enum Commands { - #[clap(name = "generate", about = "Generate foreign language bindings")] + /// Generate foreign language bindings Generate { + /// Foreign language(s) for which to build bindings. #[clap(long, short, possible_values = &["kotlin", "python", "swift", "ruby"])] - #[clap(help = "Foreign language(s) for which to build bindings.")] language: Vec, - #[clap( - long, - short, - help = "Directory in which to write generated files. Default is same folder as .udl file." - )] + /// Directory in which to write generated files. Default is same folder as .udl file. + #[clap(long, short)] out_dir: Option, - #[clap(long, short, help = "Do not try to format the generated bindings.")] + /// Do not try to format the generated bindings. + #[clap(long, short)] no_format: bool, - #[clap( - long, - short, - help = "Path to the optional uniffi config file. If not provided, uniffi-bindgen will try to guess it from the UDL's file location." - )] + /// Path to the optional uniffi config file. If not provided, uniffi-bindgen will try to guess it from the UDL's file location. + #[clap(long, short)] config: Option, - #[clap(help = "Path to the UDL file.")] + /// Path to the UDL file. udl_file: Utf8PathBuf, }, - #[clap(name = "scaffolding", about = "Generate Rust scaffolding code")] + /// Generate Rust scaffolding code Scaffolding { - #[clap( - long, - short, - help = "Directory in which to write generated files. Default is same folder as .udl file." - )] + /// Directory in which to write generated files. Default is same folder as .udl file. + #[clap(long, short)] out_dir: Option, - #[clap( - long, - short, - help = "Path to the optional uniffi config file. If not provided, uniffi-bindgen will try to guess it from the UDL's file location." - )] + /// Path to the optional uniffi config file. If not provided, uniffi-bindgen will try to guess it from the UDL's file location. + #[clap(long, short)] config: Option, - #[clap(long, short, help = "Do not try to format the generated bindings.")] + /// Do not try to format the generated bindings. + #[clap(long, short)] no_format: bool, - #[clap(help = "Path to the UDL file.")] + /// Path to the UDL file. udl_file: Utf8PathBuf, }, - #[clap( - name = "test", - about = "Run test scripts against foreign language bindings." - )] + /// Run test scripts against foreign language bindings. Test { - #[clap( - help = "Path to the directory containing the cdylib the scripts will be testing against." - )] + /// Path to the directory containing the cdylib the scripts will be testing against. cdylib_dir: Utf8PathBuf, - #[clap(help = "Path to the UDL file.")] + /// Path to the UDL file. udl_file: Utf8PathBuf, - #[clap(help = "Foreign language(s) test scripts to run.")] + /// Foreign language(s) test scripts to run. test_scripts: Vec, - #[clap( - long, - short, - help = "Path to the optional uniffi config file. If not provided, uniffi-bindgen will try to guess it from the UDL's file location." - )] + /// Path to the optional uniffi config file. If not provided, uniffi-bindgen will try to guess it from the UDL's file location. + #[clap(long, short)] config: Option, }, }