aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-10-26 18:28:09 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-10-26 18:28:09 +0000
commitae21c51b25005e1bd5b7f297beeb67a33079b1af (patch)
tree733df90168a5495c41be429dc3b1a5d12eb51f7e
parent16b2443cacab6c01ae16a46e5d95ad0729a8234f (diff)
parentf516a00dd9e34dcd3ef16c652ead66f533f6e809 (diff)
downloadargh_shared-ae21c51b25005e1bd5b7f297beeb67a33079b1af.tar.gz
Snap for 11006111 from f516a00dd9e34dcd3ef16c652ead66f533f6e809 to emu-34-release
Change-Id: Ib0971528938b74793967f818cf008b775c175a04
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp5
-rw-r--r--Cargo.toml6
-rw-r--r--Cargo.toml.orig5
-rw-r--r--METADATA10
-rw-r--r--cargo2android.json9
-rw-r--r--cargo_embargo.json11
-rw-r--r--src/lib.rs108
8 files changed, 137 insertions, 19 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
diff --git a/Android.bp b/Android.bp
index e82a725..f6e84fa 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,4 @@
-// This file is generated by cargo2android.py --config cargo2android.json.
+// This file is generated by cargo_embargo.
// Do not modify this file as changes will be overridden on upgrade.
package {
@@ -23,9 +23,10 @@ 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",
diff --git a/Cargo.toml b/Cargo.toml
index 6dd113e..2463da8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"] }
diff --git a/METADATA b/METADATA
index 0e881d1..1d5719e 100644
--- a/METADATA
+++ b/METADATA
@@ -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
}
}
diff --git a/cargo2android.json b/cargo2android.json
deleted file mode 100644
index 6e516e0..0000000
--- a/cargo2android.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "apex-available": [
- "//apex_available:platform",
- "com.android.virt"
- ],
- "device": true,
- "run": true,
- "tests": true
-} \ No newline at end of file
diff --git a/cargo_embargo.json b/cargo_embargo.json
new file mode 100644
index 0000000..d5ca5d9
--- /dev/null
+++ b/cargo_embargo.json
@@ -0,0 +1,11 @@
+{
+ "tests": true,
+ "apex_available": [
+ "//apex_available:platform",
+ "com.android.virt"
+ ],
+ "module_blocklist": [
+ "argh_shared_test_src_lib"
+ ],
+ "run_cargo": false
+}
diff --git a/src/lib.rs b/src/lib.rs
index c6e7a5c..20383a4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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;