Skip to content

Commit e24cd44

Browse files
committed
make theme optional
1 parent 689b89f commit e24cd44

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/config.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct Config {
3232
pub reexport_core_peripherals: bool,
3333
pub reexport_interrupt: bool,
3434
pub ident_formats: IdentFormats,
35-
pub ident_formats_theme: IdentFormatsTheme,
35+
pub ident_formats_theme: Option<IdentFormatsTheme>,
3636
pub base_address_shift: u64,
3737
}
3838

@@ -242,7 +242,7 @@ impl IdentFormats {
242242
]))
243243
}
244244

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

248248
let pascal = IdentFormat::default().pascal_case();
@@ -304,9 +304,7 @@ impl DerefMut for IdentFormats {
304304
derive(serde::Deserialize),
305305
serde(rename_all = "lowercase")
306306
)]
307-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
307+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
308308
pub enum IdentFormatsTheme {
309-
#[default]
310-
New,
311309
Legacy,
312310
}

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,8 @@ pub fn generate(input: &str, config: &Config) -> Result<Generation> {
625625

626626
let mut config = config.clone();
627627
let mut ident_formats = match config.ident_formats_theme {
628-
IdentFormatsTheme::New => IdentFormats::new_theme(),
629-
IdentFormatsTheme::Legacy => IdentFormats::legacy_theme(),
628+
Some(IdentFormatsTheme::Legacy) => IdentFormats::legacy_theme(),
629+
_ => IdentFormats::default_theme(),
630630
};
631631
ident_formats.extend(config.ident_formats.drain());
632632
config.ident_formats = ident_formats;

src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ fn parse_configs(app: Command) -> Result<Config> {
3434

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

0 commit comments

Comments
 (0)