diff --git a/tools/aconfig/src/codegen/cpp.rs b/tools/aconfig/src/codegen/cpp.rs index c420913644..06e5ccab75 100644 --- a/tools/aconfig/src/codegen/cpp.rs +++ b/tools/aconfig/src/codegen/cpp.rs @@ -20,7 +20,8 @@ use std::path::PathBuf; use tinytemplate::TinyTemplate; use crate::codegen; -use crate::commands::{CodegenMode, OutputFile}; +use crate::codegen::CodegenMode; +use crate::commands::OutputFile; use crate::protos::{ProtoFlagPermission, ProtoFlagState, ProtoParsedFlag}; pub fn generate_cpp_code( diff --git a/tools/aconfig/src/codegen/java.rs b/tools/aconfig/src/codegen/java.rs index f874b344d7..6a7d7c1e27 100644 --- a/tools/aconfig/src/codegen/java.rs +++ b/tools/aconfig/src/codegen/java.rs @@ -21,7 +21,8 @@ use std::path::PathBuf; use tinytemplate::TinyTemplate; use crate::codegen; -use crate::commands::{CodegenMode, OutputFile}; +use crate::codegen::CodegenMode; +use crate::commands::OutputFile; use crate::protos::{ProtoFlagPermission, ProtoFlagState, ProtoParsedFlag}; pub fn generate_java_code( diff --git a/tools/aconfig/src/codegen/mod.rs b/tools/aconfig/src/codegen/mod.rs index abc27c678f..fc61b7b27b 100644 --- a/tools/aconfig/src/codegen/mod.rs +++ b/tools/aconfig/src/codegen/mod.rs @@ -19,6 +19,7 @@ pub mod java; pub mod rust; use anyhow::{ensure, Result}; +use clap::ValueEnum; pub fn is_valid_name_ident(s: &str) -> bool { // Identifiers must match [a-z][a-z0-9_]*, except consecutive underscores are not allowed @@ -52,6 +53,13 @@ pub fn create_device_config_ident(package: &str, flag_name: &str) -> Result( diff --git a/tools/aconfig/src/commands.rs b/tools/aconfig/src/commands.rs index 5a94e023a8..23667bb9df 100644 --- a/tools/aconfig/src/commands.rs +++ b/tools/aconfig/src/commands.rs @@ -15,7 +15,6 @@ */ use anyhow::{bail, ensure, Context, Result}; -use clap::ValueEnum; use protobuf::Message; use std::io::Read; use std::path::PathBuf; @@ -23,6 +22,7 @@ use std::path::PathBuf; use crate::codegen::cpp::generate_cpp_code; use crate::codegen::java::generate_java_code; use crate::codegen::rust::generate_rust_code; +use crate::codegen::CodegenMode; use crate::dump::{DumpFormat, DumpPredicate}; use crate::protos::{ ParsedFlagExt, ProtoFlagMetadata, ProtoFlagPermission, ProtoFlagState, ProtoParsedFlag, @@ -188,13 +188,6 @@ pub fn parse_flags( Ok(output) } -#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)] -pub enum CodegenMode { - Production, - Test, - Exported, -} - pub fn create_java_lib(mut input: Input, codegen_mode: CodegenMode) -> Result> { let parsed_flags = input.try_parse_flags()?; let filtered_parsed_flags = filter_parsed_flags(parsed_flags, codegen_mode); diff --git a/tools/aconfig/src/main.rs b/tools/aconfig/src/main.rs index fcc5ea5085..c6adff73cd 100644 --- a/tools/aconfig/src/main.rs +++ b/tools/aconfig/src/main.rs @@ -30,12 +30,13 @@ mod dump; mod protos; mod storage; +use codegen::CodegenMode; use dump::DumpFormat; #[cfg(test)] mod test; -use commands::{CodegenMode, Input, OutputFile}; +use commands::{Input, OutputFile}; const HELP_DUMP_FILTER: &str = r#" Limit which flags to output. If multiple --filter arguments are provided, the output will be @@ -69,7 +70,7 @@ fn cli() -> Command { .arg( Arg::new("mode") .long("mode") - .value_parser(EnumValueParser::::new()) + .value_parser(EnumValueParser::::new()) .default_value("production"), ), ) @@ -80,7 +81,7 @@ fn cli() -> Command { .arg( Arg::new("mode") .long("mode") - .value_parser(EnumValueParser::::new()) + .value_parser(EnumValueParser::::new()) .default_value("production"), ), ) @@ -91,7 +92,7 @@ fn cli() -> Command { .arg( Arg::new("mode") .long("mode") - .value_parser(EnumValueParser::::new()) + .value_parser(EnumValueParser::::new()) .default_value("production"), ), ) @@ -114,7 +115,12 @@ fn cli() -> Command { .value_parser(|s: &str| DumpFormat::try_from(s)) .default_value("text"), ) - .arg(Arg::new("filter").long("filter").action(ArgAction::Append).help(HELP_DUMP_FILTER.trim())) + .arg( + Arg::new("filter") + .long("filter") + .action(ArgAction::Append) + .help(HELP_DUMP_FILTER.trim()), + ) .arg(Arg::new("dedup").long("dedup").num_args(0).action(ArgAction::SetTrue)) .arg(Arg::new("out").long("out").default_value("-")), )