diff options
author | Andrew Walbran <qwandor@google.com> | 2023-10-19 21:15:47 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-10-19 21:15:47 +0000 |
commit | 72db044d54cea8eab237b4828db604a7dbc5c08b (patch) | |
tree | 4979a6244d435bc3698ba38faf64254827105eee | |
parent | 668a0bc8be126c546c791389fc9d76c6cd24b1aa (diff) | |
parent | 0698a695f81282865e807da2d65ef10d96f4991a (diff) | |
download | argh_shared-72db044d54cea8eab237b4828db604a7dbc5c08b.tar.gz |
Upgrade argh_shared to 0.1.12 am: be814f4134 am: 0bdfd52d6f am: 0698a695f8
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/argh_shared/+/2797612
Change-Id: I33a0d658b8319096fd15afe3664d9846af8090e9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 5 | ||||
-rw-r--r-- | Cargo.toml | 6 | ||||
-rw-r--r-- | Cargo.toml.orig | 5 | ||||
-rw-r--r-- | METADATA | 10 | ||||
-rw-r--r-- | src/lib.rs | 108 |
6 files changed, 127 insertions, 9 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 18c719f..7d20ae0 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "3f3c29726a21c4b541bb2b9aa2c592461897ded0" + "sha1": "e8efc8285f632a4ebedfe4377e0f1d78276f8e19" }, "path_in_vcs": "argh_shared" }
\ No newline at end of file @@ -23,9 +23,12 @@ rust_library { host_supported: true, crate_name: "argh_shared", cargo_env_compat: true, - cargo_pkg_version: "0.1.10", + cargo_pkg_version: "0.1.12", srcs: ["src/lib.rs"], edition: "2018", + rustlibs: [ + "libserde", + ], apex_available: [ "//apex_available:platform", "com.android.virt", @@ -12,7 +12,7 @@ [package] edition = "2018" name = "argh_shared" -version = "0.1.10" +version = "0.1.12" authors = [ "Taylor Cramer <cramertj@google.com>", "Benjamin Brittain <bwb@google.com>", @@ -22,3 +22,7 @@ description = "Derive-based argument parsing optimized for code size" readme = "README.md" license = "BSD-3-Clause" repository = "https://github.com/google/argh" + +[dependencies.serde] +version = "1" +features = ["derive"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 0f4478a..8e07308 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,9 +1,12 @@ [package] name = "argh_shared" -version = "0.1.10" +version = "0.1.12" authors = ["Taylor Cramer <cramertj@google.com>", "Benjamin Brittain <bwb@google.com>", "Erick Tryzelaar <etryzelaar@google.com>"] edition = "2018" license = "BSD-3-Clause" description = "Derive-based argument parsing optimized for code size" repository = "https://github.com/google/argh" readme = "README.md" + +[dependencies] +serde = { version = "1", features = ["derive"] } @@ -1,6 +1,6 @@ # This project was upgraded with external_updater. # Usage: tools/external_updater/updater.sh update rust/crates/argh_shared -# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md +# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md name: "argh_shared" description: "Derive-based argument parsing optimized for code size" @@ -11,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/argh_shared/argh_shared-0.1.10.crate" + value: "https://static.crates.io/crates/argh_shared/argh_shared-0.1.12.crate" } - version: "0.1.10" + version: "0.1.12" license_type: NOTICE last_upgrade_date { year: 2023 - month: 2 - day: 1 + month: 10 + day: 19 } } @@ -14,6 +14,114 @@ pub struct CommandInfo<'a> { pub description: &'a str, } +/// Information about the command line arguments for a given command. +#[derive(Debug, Default, PartialEq, Eq, Clone, serde::Serialize)] +pub struct CommandInfoWithArgs<'a> { + /// The name of the command. + pub name: &'a str, + /// A short description of the command's functionality. + pub description: &'a str, + /// Examples of usage + pub examples: &'a [&'a str], + /// Flags + pub flags: &'a [FlagInfo<'a>], + /// Notes about usage + pub notes: &'a [&'a str], + /// The subcommands. + pub commands: Vec<SubCommandInfo<'a>>, + /// Positional args + pub positionals: &'a [PositionalInfo<'a>], + /// Error code information + pub error_codes: &'a [ErrorCodeInfo<'a>], +} + +/// Information about a documented error code. +#[derive(Debug, PartialEq, Eq, serde::Serialize)] +pub struct ErrorCodeInfo<'a> { + /// The code value. + pub code: i32, + /// Short description about what this code indicates. + pub description: &'a str, +} + +/// Information about positional arguments +#[derive(Debug, PartialEq, Eq, serde::Serialize)] +pub struct PositionalInfo<'a> { + /// Name of the argument. + pub name: &'a str, + /// Description of the argument. + pub description: &'a str, + /// Optionality of the argument. + pub optionality: Optionality, + /// Visibility in the help for this argument. + /// `false` indicates this argument will not appear + /// in the help message. + pub hidden: bool, +} + +/// Information about a subcommand. +/// Dynamic subcommands do not implement +/// get_args_info(), so the command field +/// only contains the name and description. +#[derive(Debug, Default, PartialEq, Eq, Clone, serde::Serialize)] +pub struct SubCommandInfo<'a> { + /// The subcommand name. + pub name: &'a str, + /// The information about the subcommand. + pub command: CommandInfoWithArgs<'a>, +} + +/// Information about a flag or option. +#[derive(Debug, Default, PartialEq, Eq, serde::Serialize)] +pub struct FlagInfo<'a> { + /// The kind of flag. + pub kind: FlagInfoKind<'a>, + /// The optionality of the flag. + pub optionality: Optionality, + /// The long string of the flag. + pub long: &'a str, + /// The single character short indicator + /// for trhis flag. + pub short: Option<char>, + /// The description of the flag. + pub description: &'a str, + /// Visibility in the help for this argument. + /// `false` indicates this argument will not appear + /// in the help message. + pub hidden: bool, +} + +/// The kind of flags. +#[derive(Debug, Default, PartialEq, Eq, serde::Serialize)] +pub enum FlagInfoKind<'a> { + /// switch represents a boolean flag, + #[default] + Switch, + /// option is a flag that also has an associated + /// value. This value is named `arg_name`. + Option { arg_name: &'a str }, +} + +/// The optionality defines the requirments related +/// to the presence of the argument on the command line. +#[derive(Debug, Default, PartialEq, Eq, serde::Serialize)] +pub enum Optionality { + /// Required indicates the argument is required + /// exactly once. + #[default] + Required, + /// Optional indicates the argument may or may not + /// be present. + Optional, + /// Repeating indicates the argument may appear zero + /// or more times. + Repeating, + /// Greedy is used for positional arguments which + /// capture the all command line input upto the next flag or + /// the end of the input. + Greedy, +} + pub const INDENT: &str = " "; const DESCRIPTION_INDENT: usize = 20; const WRAP_WIDTH: usize = 80; |