diff options
Diffstat (limited to 'mingling_picker/src/parselib')
| -rw-r--r-- | mingling_picker/src/parselib/style.rs | 49 | ||||
| -rw-r--r-- | mingling_picker/src/parselib/utils.rs | 5 |
2 files changed, 46 insertions, 8 deletions
diff --git a/mingling_picker/src/parselib/style.rs b/mingling_picker/src/parselib/style.rs index 4ea161f..3c37b2d 100644 --- a/mingling_picker/src/parselib/style.rs +++ b/mingling_picker/src/parselib/style.rs @@ -109,25 +109,58 @@ impl<'a> From<&'a String> for FlagStr<'a> { } } +/// Defines the naming convention for command-line option names. +/// +/// Each variant represents a different case format that can be applied +/// to option names (e.g., long option names) during parsing or generation. +/// +/// # Examples +/// +/// ``` +/// # use mingling_picker::IntoPicker; +/// use mingling_picker::parselib::ParserStyleNamingCase; +/// +/// let case = ParserStyleNamingCase::Kebab; +/// assert_eq!( +/// case.convert("brew_coffee".to_string()), +/// "brew-coffee".to_string() +/// ); +/// ``` #[repr(u8)] #[derive(Default, Clone, Copy, PartialEq, Eq)] pub enum ParserStyleNamingCase { - /// snake_case format (e.g., `brew_coffee`) + /// snake_case format: words are separated by underscores, all lowercase. + /// + /// Example: `brew_coffee` #[default] Snake, - /// camelCase format (e.g., `brewCoffee`) + /// camelCase format: first word is lowercase, subsequent words are capitalized. + /// + /// Example: `brewCoffee` Camel, - /// PascalCase format (e.g., `BrewCoffee`) + /// PascalCase format: every word starts with an uppercase letter. + /// + /// Example: `BrewCoffee` Pascal, - /// kebab-case format (e.g., `brew-coffee`) + /// kebab-case format: words are separated by hyphens, all lowercase. + /// + /// Example: `brew-coffee` Kebab, - /// dot.case format (e.g., `brew.coffee`) + /// dot.case format: words are separated by dots, all lowercase. + /// + /// Example: `brew.coffee` Dot, - /// Title Case format (e.g., `Brew Coffee`) + /// Title Case format: words are separated by spaces, each word capitalized. + /// + /// Example: `Brew Coffee` Title, - /// lower case format (e.g., `brew coffee`) + /// lower case format: words are separated by spaces, all lowercase. + /// + /// Example: `brew coffee` Lower, - /// UPPER CASE format (e.g., `BREW COFFEE`) + /// UPPER CASE format: words are separated by spaces, all uppercase. + /// + /// Example: `BREW COFFEE` Upper, } diff --git a/mingling_picker/src/parselib/utils.rs b/mingling_picker/src/parselib/utils.rs index 726346c..47c5b55 100644 --- a/mingling_picker/src/parselib/utils.rs +++ b/mingling_picker/src/parselib/utils.rs @@ -3,6 +3,11 @@ use crate::{ parselib::{MaskedArg, ParserStyle}, }; +/// Builds a list of possible flag strings for the given argument info +/// +/// This function generates formatted flag strings (e.g., `-h`, `--help`) from the short flag, +/// long flag, and any aliases defined in the argument info. The long flag and alias names +/// are converted according to the style's naming case convention before being formatted. #[inline(always)] pub fn build_possible_flags(style: &ParserStyle, arg_info: &PickerArgInfo) -> Vec<String> { let mut possible_flags = vec![]; |
