From a95f2b230cbf68b5b373c649ce11b8c2f231b97d Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Wed, 6 Dec 2023 00:46:01 +0000 Subject: [PATCH] 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 --- tools/aconfig/src/commands.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/aconfig/src/commands.rs b/tools/aconfig/src/commands.rs index 1e80d267e2..39e0154a8d 100644 --- a/tools/aconfig/src/commands.rs +++ b/tools/aconfig/src/commands.rs @@ -268,6 +268,7 @@ pub enum DumpFormat { Verbose, Protobuf, Textproto, + Bool, } pub fn dump_parsed_flags( @@ -318,6 +319,17 @@ pub fn dump_parsed_flags( 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) }