Add new dump format map in aconfig
The `aconfig dump --format map` lists aconfig keys mapped to its boolean
values that represents whether the flag is enabled or not, as seen below:
```
flag.name1=true
flag.name2=false
```
Test: aconfig dump --format map --cache out/soong/.intermediates/build/make/tools/aconfig/aconfig.test.flags/intermediate.pb && inspect output
Bug: 306024510
Change-Id: Ic4990c168f6fa9c87869113ba695c07394adbc67
diff --git a/tools/aconfig/src/commands.rs b/tools/aconfig/src/commands.rs
index 1e80d26..39e0154 100644
--- a/tools/aconfig/src/commands.rs
+++ b/tools/aconfig/src/commands.rs
@@ -268,6 +268,7 @@
Verbose,
Protobuf,
Textproto,
+ Bool,
}
pub fn dump_parsed_flags(
@@ -318,6 +319,17 @@
let s = protobuf::text_format::print_to_string_pretty(&parsed_flags);
output.extend_from_slice(s.as_bytes());
}
+ DumpFormat::Bool => {
+ for parsed_flag in parsed_flags.parsed_flag.into_iter() {
+ let line = format!(
+ "{}.{}={:?}\n",
+ parsed_flag.package(),
+ parsed_flag.name(),
+ parsed_flag.state() == ProtoFlagState::ENABLED
+ );
+ output.extend_from_slice(line.as_bytes());
+ }
+ }
}
Ok(output)
}