Skip to content

Commit

Permalink
make theme optional
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Feb 18, 2024
1 parent 6969a74 commit 85c54d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct Config {
pub reexport_core_peripherals: bool,
pub reexport_interrupt: bool,
pub ident_formats: IdentFormats,
pub ident_formats_theme: IdentFormatsTheme,
pub ident_formats_theme: Option<IdentFormatsTheme>,
pub base_address_shift: u64,
}

Expand Down Expand Up @@ -242,7 +242,7 @@ impl IdentFormats {
]))
}

pub fn new_theme() -> Self {
pub fn default_theme() -> Self {
let mut map = Self::common();

let pascal = IdentFormat::default().pascal_case();
Expand Down Expand Up @@ -304,9 +304,7 @@ impl DerefMut for IdentFormats {
derive(serde::Deserialize),
serde(rename_all = "lowercase")
)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum IdentFormatsTheme {
#[default]
New,
Legacy,
}
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ pub fn generate(input: &str, config: &Config) -> Result<Generation> {

let mut config = config.clone();
let mut ident_formats = match config.ident_formats_theme {
IdentFormatsTheme::New => IdentFormats::new_theme(),
IdentFormatsTheme::Legacy => IdentFormats::legacy_theme(),
Some(IdentFormatsTheme::Legacy) => IdentFormats::legacy_theme(),
_ => IdentFormats::default_theme(),
};
ident_formats.extend(config.ident_formats.drain());
config.ident_formats = ident_formats;
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ fn parse_configs(app: Command) -> Result<Config> {

let mut config: Config = irxconfig.get()?;
let mut idf = match config.ident_formats_theme {
IdentFormatsTheme::New => IdentFormats::new_theme(),
IdentFormatsTheme::Legacy => IdentFormats::legacy_theme(),
Some(IdentFormatsTheme::Legacy) => IdentFormats::legacy_theme(),
_ => IdentFormats::default_theme(),
};
idf.extend(config.ident_formats.drain());
config.ident_formats = idf;
Expand Down Expand Up @@ -166,7 +166,7 @@ fn run() -> Result<()> {
format!("Specify `-f type:prefix:case:suffix` to change default ident formatting.
Allowed values of `type` are {:?}.
Allowed cases are `unchanged` (''), `pascal` ('p'), `constant` ('c') and `snake` ('s').
", IdentFormats::new_theme().keys().collect::<Vec<_>>())
", IdentFormats::default_theme().keys().collect::<Vec<_>>())
),
)
.arg(
Expand Down

0 comments on commit 85c54d7

Please sign in to comment.