clappos 0.1.0

A simple, flagless version of Clap
Documentation
use proc_macro::TokenStream;

#[proc_macro_derive(Snap)]
pub fn derive_snap(item: TokenStream) -> TokenStream {
    println!("{item}");
    let mut lines = item.to_string().split("\n").map(|s| s.trim().to_string()).collect::<Vec<String>>();
    println!("{lines:?}");
    let mut struct_comments = vec![];
    while lines[0].starts_with("///") {
        struct_comments.push(lines.remove(0));
    }
    let struct_name =
        lines.remove(0)
            .split(' ')
            .map(|s| s.to_string())
            .collect::<Vec<String>>()
            .into_iter()
            .find(|s| {
                let first_char = s.as_bytes()[0];
                first_char >= 0x41 && first_char <= 0x5a    // the utf8 range of capital letters
            })
            .expect("didn't find struct name?").to_string();
    let mut idents = vec![];
    let mut types = vec![];
    let mut comments = vec![];
    let mut type_expected = false;
    let mut type_found = false;
    lines.into_iter().for_each(|line| {
        if line.starts_with("///") {
            comments.push(line);
        } else if line.len() > 1 {
            let tokens = line.split(' ').map(|s| s.to_string()).collect::<Vec<String>>();
            for token in tokens.iter() {
                let mut token = token.to_string();
                println!("checking {token} for ident/type");
                if type_found {
                    comments.push(tokens.join(" "));
                    type_found = false;
                    break;
                } else if token.ends_with(':') {
                    token.remove(token.len() - 1);
                    idents.push(token);
                    type_expected = true;
                } else if type_expected {
                    if token.ends_with(',') {
                        token.remove(token.len() - 1);
                    }
                    types.push(token);
                    type_expected = false;
                    type_found = true;
                }
            }

        }

    });


    println!("STRUCT NAME: {struct_name}");
    println!("IDENTS: {idents:?}");
    println!("TYPES: {types:?}");
    TokenStream::new()
}