summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-01-28 08:31:37 -0800
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2025-01-28 08:31:37 -0800
commit7086cd3fe009aa357b361b472dfd3840e6586b0c (patch)
tree2e22f94a46c32be9e928c4e93459b00a9dacb059
parent7a208afc4403afbd63d6238f2ce6951e791e5a03 (diff)
parent4cd11e5e7b2f70a92b6f3373821b364d90e423d1 (diff)
Merge "aconfig: document the dump --filter and --format arguments" into main am: ed49df9aa3 am: 4cd11e5e7b
Original change: https://android-review.googlesource.com/c/platform/build/+/3466706 Change-Id: I2f6ef31b8780312c8e0cf688976842859e90cdbf Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--tools/aconfig/aconfig/src/main.rs101
1 files changed, 95 insertions, 6 deletions
diff --git a/tools/aconfig/aconfig/src/main.rs b/tools/aconfig/aconfig/src/main.rs
index e2fa554b9a..14bbcc3348 100644
--- a/tools/aconfig/aconfig/src/main.rs
+++ b/tools/aconfig/aconfig/src/main.rs
@@ -40,9 +40,86 @@ mod test;
use commands::{Input, OutputFile};
+const HELP_DUMP_CACHE: &str = r#"
+An aconfig cache file, created via `aconfig create-cache`.
+"#;
+
+const HELP_DUMP_FORMAT: &str = r#"
+Change the output format for each flag.
+
+The argument to --format is a format string. Each flag will be a copy of this string, with certain
+placeholders replaced by attributes of the flag. The placeholders are
+
+ {package}
+ {name}
+ {namespace}
+ {description}
+ {bug}
+ {state}
+ {state:bool}
+ {permission}
+ {trace}
+ {trace:paths}
+ {is_fixed_read_only}
+ {is_exported}
+ {container}
+ {metadata}
+ {fully_qualified_name}
+
+Note: the format strings "textproto" and "protobuf" are handled in a special way: they output all
+flag attributes in text or binary protobuf format.
+
+Examples:
+
+ # See which files were read to determine the value of a flag; the files were read in the order
+ # listed.
+ --format='{fully_qualified_name} {trace}'
+
+ # Trace the files read for a specific flag. Useful during debugging.
+ --filter=fully_qualified_name:com.foo.flag_name --format='{trace}'
+
+ # Print a somewhat human readable description of each flag.
+ --format='The flag {name} in package {package} is {state} and has permission {permission}.'
+"#;
+
const HELP_DUMP_FILTER: &str = r#"
-Limit which flags to output. If multiple --filter arguments are provided, the output will be
-limited to flags that match any of the filters.
+Limit which flags to output. If --filter is omitted, all flags will be printed. If multiple
+--filter options are provided, the output will be limited to flags that match any of the filters.
+
+The argument to --filter is a search query. Multiple queries can be AND-ed together by
+concatenating them with a plus sign.
+
+Valid queries are:
+
+ package:<string>
+ name:<string>
+ namespace:<string>
+ bug:<string>
+ state:ENABLED|DISABLED
+ permission:READ_ONLY|READ_WRITE
+ is_fixed_read_only:true|false
+ is_exported:true|false
+ container:<string>
+ fully_qualified_name:<string>
+
+Note: there is currently no support for filtering based on these flag attributes: description,
+trace, metadata.
+
+Examples:
+
+ # Print a single flag:
+ --filter=fully_qualified_name:com.foo.flag_name
+
+ # Print all known information about a single flag:
+ --filter=fully_qualified_name:com.foo.flag_name --format=textproto
+
+ # Print all flags in the com.foo package, and all enabled flags in the com.bar package:
+ --filter=package:com.foo --filter=package.com.bar+state:ENABLED
+"#;
+
+const HELP_DUMP_DEDUP: &str = r#"
+Allow the same flag to be present in multiple cache files; if duplicates are found, collapse into
+a single instance.
"#;
fn cli() -> Command {
@@ -150,22 +227,34 @@ fn cli() -> Command {
.subcommand(
Command::new("dump-cache")
.alias("dump")
- .arg(Arg::new("cache").long("cache").action(ArgAction::Append))
+ .arg(
+ Arg::new("cache")
+ .long("cache")
+ .action(ArgAction::Append)
+ .long_help(HELP_DUMP_CACHE.trim()),
+ )
.arg(
Arg::new("format")
.long("format")
.value_parser(|s: &str| DumpFormat::try_from(s))
.default_value(
"{fully_qualified_name} [{container}]: {permission} + {state}",
- ),
+ )
+ .long_help(HELP_DUMP_FORMAT.trim()),
)
.arg(
Arg::new("filter")
.long("filter")
.action(ArgAction::Append)
- .help(HELP_DUMP_FILTER.trim()),
+ .long_help(HELP_DUMP_FILTER.trim()),
+ )
+ .arg(
+ Arg::new("dedup")
+ .long("dedup")
+ .num_args(0)
+ .action(ArgAction::SetTrue)
+ .long_help(HELP_DUMP_DEDUP.trim()),
)
- .arg(Arg::new("dedup").long("dedup").num_args(0).action(ArgAction::SetTrue))
.arg(Arg::new("out").long("out").default_value("-")),
)
.subcommand(