Merge pull request #25 from nanpuyue/fix-rename-rules

fix: rename_by_rule
This commit is contained in:
Hirrolot 2022-05-26 23:11:04 +06:00 committed by GitHub
commit e344b11dcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -24,7 +24,14 @@ impl CommandEnum {
}
if let Some(rename_rule) = &rename {
match rename_rule.as_str() {
"lowercase" => {}
"lowercase"
| "UPPERCASE"
| "PascalCase"
| "camelCase"
| "snake_case"
| "SCREAMING_SNAKE_CASE"
| "kebab-case"
| "SCREAMING-KEBAB-CASE" => {}
_ => return Err("disallowed value".to_owned()),
}
}

View file

@ -21,7 +21,7 @@ pub fn rename_by_rule(input: &str, rule: &str) -> String {
"SCREAMING_SNAKE_CASE" => input.to_shouty_snake_case(),
"kebab-case" => input.to_kebab_case(),
"SCREAMING-KEBAB-CASE" => input.to_shouty_kebab_case(),
_ => input.to_string(),
_ => rule.to_string(),
}
}