mod query;
mod switchboard;
mod value;

pub use query::*;
pub use switchboard::*;
pub use value::*;

use log::*;


pub enum SwitchName {
    Short(char),
    Long(String),
}

impl std::fmt::Display for SwitchName {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
        match self {
            SwitchName::Short(c) => write!(f, "-{c}"),
            SwitchName::Long(s) => write!(f, "--{s}"),
        }
    }
}

pub enum SwitchboardError {
    Malformed(String),
    MissingNamed(String),
    MissingPositional(String),
    // String is the debug name of the switch
    Repeated(String),
}

fn validate_name(name: &str) {
    if !name.chars().all(|c| c.is_ascii_lowercase() || c.is_digit(10) || c == '-') {
        log::fatal!("Invalid name for argument: {name:?}");
    }
}