aconfig: rename enum Format -> enum DumpFormat

Rename enum Format to enum DumpFormat to make it more apparent what it
refers to.

Bug: 279485059
Test: atest aconfig.test
Change-Id: I869be020b69618b036fa05247f155d9e35ff85e2
This commit is contained in:
Mårten Kongstad 2023-05-16 11:00:16 +02:00
parent 7f1171e493
commit ba94e6a6b2
2 changed files with 8 additions and 8 deletions

View file

@ -96,29 +96,29 @@ pub fn generate_code(cache: &Cache) -> Result<OutputFile> {
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
pub enum Format {
pub enum DumpFormat {
Text,
Debug,
Protobuf,
}
pub fn dump_cache(cache: Cache, format: Format) -> Result<Vec<u8>> {
pub fn dump_cache(cache: Cache, format: DumpFormat) -> Result<Vec<u8>> {
match format {
Format::Text => {
DumpFormat::Text => {
let mut lines = vec![];
for item in cache.iter() {
lines.push(format!("{}: {:?}\n", item.name, item.state));
}
Ok(lines.concat().into())
}
Format::Debug => {
DumpFormat::Debug => {
let mut lines = vec![];
for item in cache.iter() {
lines.push(format!("{:?}\n", item));
}
Ok(lines.concat().into())
}
Format::Protobuf => {
DumpFormat::Protobuf => {
let parsed_flags: ProtoParsedFlags = cache.into();
let mut output = vec![];
parsed_flags.write_to_vec(&mut output)?;
@ -168,7 +168,7 @@ mod tests {
#[test]
fn test_dump_text_format() {
let cache = create_test_cache();
let bytes = dump_cache(cache, Format::Text).unwrap();
let bytes = dump_cache(cache, DumpFormat::Text).unwrap();
let text = std::str::from_utf8(&bytes).unwrap();
assert!(text.contains("a: Disabled"));
}
@ -179,7 +179,7 @@ mod tests {
use protobuf::Message;
let cache = create_test_cache();
let bytes = dump_cache(cache, Format::Protobuf).unwrap();
let bytes = dump_cache(cache, DumpFormat::Protobuf).unwrap();
let actual = ProtoParsedFlags::parse_from_bytes(&bytes).unwrap();
assert_eq!(

View file

@ -53,7 +53,7 @@ fn cli() -> Command {
.arg(
Arg::new("format")
.long("format")
.value_parser(EnumValueParser::<commands::Format>::new())
.value_parser(EnumValueParser::<commands::DumpFormat>::new())
.default_value("text"),
)
.arg(Arg::new("out").long("out").default_value("-")),