From 6f4eaaf8a8f29061c20f382c771991bb83221f7a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 20 Apr 2020 04:07:39 -0400 Subject: add docs --- Cargo.lock | 13 ++++ Cargo.toml | 2 +- src/bin/rbw/main.rs | 214 +++++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 192 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9595645..55912d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -249,6 +249,7 @@ dependencies = [ "atty", "bitflags", "strsim 0.8.0", + "term_size", "textwrap", "unicode-width", "vec_map", @@ -1484,6 +1485,17 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "term_size" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" +dependencies = [ + "kernel32-sys", + "libc", + "winapi 0.2.8", +] + [[package]] name = "termcolor" version = "1.1.0" @@ -1499,6 +1511,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ + "term_size", "unicode-width", ] diff --git a/Cargo.toml b/Cargo.toml index 7084172..97f3762 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ arrayvec = "0.5" base64 = "0.11" block-modes = "0.3" chbs = "0.0.10" -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } daemonize = "0.4" directories = "2.0" env_logger = "0.7" diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs index 9bdb1b6..f763fe9 100644 --- a/src/bin/rbw/main.rs +++ b/src/bin/rbw/main.rs @@ -11,110 +11,252 @@ fn main() { .init(); let matches = clap::App::new("rbw") - .about("unofficial bitwarden cli") + .about("Unofficial Bitwarden CLI") .author(clap::crate_authors!()) .version(clap::crate_version!()) .subcommand( clap::SubCommand::with_name("config") - .subcommand(clap::SubCommand::with_name("show")) + .about("Get or set configuration options") + .subcommand( + clap::SubCommand::with_name("show").about( + "Show the values of all configuration settings", + ), + ) .subcommand( clap::SubCommand::with_name("set") - .arg(clap::Arg::with_name("key").required(true)) - .arg(clap::Arg::with_name("value").required(true)), + .about("Set a configuration option") + .arg( + clap::Arg::with_name("key") + .required(true) + .help("Configuration key to set"), + ) + .arg( + clap::Arg::with_name("value") + .required(true) + .help( + "Value to set the configuration option to", + ), + ), ), ) - .subcommand(clap::SubCommand::with_name("login")) - .subcommand(clap::SubCommand::with_name("unlock")) - .subcommand(clap::SubCommand::with_name("sync")) + .subcommand( + clap::SubCommand::with_name("login") + .about("Log in to the Bitwarden server"), + ) + .subcommand( + clap::SubCommand::with_name("unlock") + .about("Unlock the local Bitwarden database"), + ) + .subcommand( + clap::SubCommand::with_name("sync") + .about("Update the local copy of the Bitwarden database"), + ) .subcommand( clap::SubCommand::with_name("list") + .about("List all entries in the local Bitwarden database") .arg( clap::Arg::with_name("fields") .long("fields") .takes_value(true) .use_delimiter(true) - .multiple(true), + .multiple(true) + .help( + "Fields to display. \ + Available options are id, name, user, folder. \ + Multiple fields will be separated by tabs.", + ), ) - .alias("ls"), + .visible_alias("ls"), ) .subcommand( clap::SubCommand::with_name("get") - .arg(clap::Arg::with_name("name").required(true)) - .arg(clap::Arg::with_name("user")) - .arg(clap::Arg::with_name("full").long("full")), + .about("Display the password for a given entry") + .arg( + clap::Arg::with_name("name") + .required(true) + .help("Name of the entry to display"), + ) + .arg( + clap::Arg::with_name("user") + .help("Username of the entry to display"), + ) + .arg( + clap::Arg::with_name("full").long("full").help( + "Display the notes in addition to the password", + ), + ), ) .subcommand( clap::SubCommand::with_name("add") - .arg(clap::Arg::with_name("name").required(true)) - .arg(clap::Arg::with_name("user")) + .about("Add a new password to the database") + .long_about( + "Add a new password to the database\n\n\ + This command will open a text editor to enter \ + the password and notes. The editor to use is determined \ + by the value of the $EDITOR environment variable. The \ + first line will be saved as the password and the \ + remainder will be saved as a note.", + ) + .arg( + clap::Arg::with_name("name") + .required(true) + .help("Name of the password entry"), + ) + .arg( + clap::Arg::with_name("user") + .help("Username for the password entry"), + ) .arg( clap::Arg::with_name("uri") .long("uri") .takes_value(true) .multiple(true) .number_of_values(1) - .use_delimiter(false), + .use_delimiter(false) + .help("URI for the password entry"), ) .arg( clap::Arg::with_name("folder") .long("folder") - .takes_value(true), + .takes_value(true) + .help("Folder for the password entry"), ), ) .subcommand( clap::SubCommand::with_name("generate") - .arg(clap::Arg::with_name("len").required(true)) - .arg(clap::Arg::with_name("name")) - .arg(clap::Arg::with_name("user")) + .about("Generate a new password") + .long_about( + "Generate a new password\n\n\ + If given a password entry name, also save the generated \ + password to the database.", + ) + .arg( + clap::Arg::with_name("len") + .required(true) + .help("Length of the password to generate"), + ) + .arg( + clap::Arg::with_name("name") + .help("Name of the password entry"), + ) + .arg( + clap::Arg::with_name("user") + .help("Username for the password entry"), + ) .arg( clap::Arg::with_name("uri") .long("uri") .takes_value(true) .multiple(true) .number_of_values(1) - .use_delimiter(false), + .use_delimiter(false) + .help("URI for the password entry"), ) .arg( clap::Arg::with_name("folder") .long("folder") - .takes_value(true), + .takes_value(true) + .help("Folder for the password entry"), ) - .arg(clap::Arg::with_name("no-symbols").long("no-symbols")) .arg( - clap::Arg::with_name("only-numbers").long("only-numbers"), + clap::Arg::with_name("no-symbols") + .long("no-symbols") + .help( + "Generate a password with no special characters", + ), + ) + .arg( + clap::Arg::with_name("only-numbers") + .long("only-numbers") + .help( + "Generate a password consisting of only numbers", + ), ) .arg( clap::Arg::with_name("nonconfusables") - .long("nonconfusables"), + .long("nonconfusables") + .help( + "Generate a password without visually similar \ + characters (useful for passwords intended to be \ + written down)", + ), ) - .arg(clap::Arg::with_name("diceware").long("diceware")) + .arg(clap::Arg::with_name("diceware").long("diceware").help( + "Generate a password of multiple dictionary \ + words chosen from the EFF word list. The len \ + parameter for this option will set the number \ + of words to generate, rather than characters.", + )) .group(clap::ArgGroup::with_name("password-type").args(&[ "no-symbols", "only-numbers", "nonconfusables", "diceware", ])) - .alias("gen"), + .visible_alias("gen"), ) .subcommand( clap::SubCommand::with_name("edit") - .arg(clap::Arg::with_name("name").required(true)) - .arg(clap::Arg::with_name("user")), + .about("Modify an existing password") + .long_about( + "Modify an existing password\n\n\ + This command will open a text editor with the existing \ + password and notes of the given entry for editing. \ + The editor to use is determined by the value of the \ + $EDITOR environment variable. The first line will be \ + saved as the password and the remainder will be saved \ + as a note.", + ) + .arg( + clap::Arg::with_name("name") + .required(true) + .help("Name of the password entry"), + ) + .arg( + clap::Arg::with_name("user") + .help("Username for the password entry"), + ), ) .subcommand( clap::SubCommand::with_name("remove") - .arg(clap::Arg::with_name("name").required(true)) - .arg(clap::Arg::with_name("user")) - .alias("rm"), + .about("Remove a given entry") + .arg( + clap::Arg::with_name("name") + .required(true) + .help("Name of the password entry"), + ) + .arg( + clap::Arg::with_name("user") + .help("Username for the password entry"), + ) + .visible_alias("rm"), ) .subcommand( clap::SubCommand::with_name("history") - .arg(clap::Arg::with_name("name").required(true)) - .arg(clap::Arg::with_name("user")), + .about("View the password history for a given entry") + .arg( + clap::Arg::with_name("name") + .required(true) + .help("Name of the password entry"), + ) + .arg( + clap::Arg::with_name("user") + .help("Username for the password entry"), + ), + ) + .subcommand( + clap::SubCommand::with_name("lock") + .about("Lock the password database"), + ) + .subcommand( + clap::SubCommand::with_name("purge") + .about("Remove the local copy of the password database"), + ) + .subcommand( + clap::SubCommand::with_name("stop-agent") + .about("Terminate the background agent") + .visible_alias("logout"), ) - .subcommand(clap::SubCommand::with_name("lock")) - .subcommand(clap::SubCommand::with_name("purge")) - .subcommand(clap::SubCommand::with_name("stop-agent").alias("logout")) .get_matches(); let res = match matches.subcommand() { -- cgit v1.2.3-54-g00ecf