My new code landludge! Kimber code

⚓ Rust    📅 2026-03-24    👤 surdeus    👁️ 1      

surdeus

use std::io;

macro_rules! ducktype {
    () => { println!("<!Ducktype!>"); };
}

fn main() {
    println!("Start coding in Kimber code!↓");
    println!("Type commands (type <End> to stop)");

    loop {
        let mut input = String::new();
        io::stdin().read_line(&mut input).expect("Failed to read line");
        let input = input.trim();

        if input == "<End>" {
            println!("Stopping Kimber Code...");
            break;
        } else if input.starts_with("//") || input.is_empty() {
            continue;
        } else if input == "<Ducktype!>" {
            ducktype!();
        } else if input == "<Element!>" {
            println!("[Element created]");
        } else if input.starts_with("<Hedder!H1{") && input.ends_with("}>") {
            let content = &input[11..input.len() - 2];
            println!("====================\n{}\n====================", content.to_uppercase());
        } else if input == "<3D!>" {
            println!("[3D mode inversion]");
        } else if input.starts_with("<Font{") && input.contains("}>") {
        
            // Safer parsing using split
            
            let font = input.trim_start_matches("<Font{").split('}').next().unwrap_or("Default");
            println!("Font changed to: {}", font);
        } else if input.starts_with("<Text{") && input.ends_with("}>") {
            println!("{}", &input[6..input.len() - 2]);
        } else {
            println!("Unknown command: {}", input);
        }
    }
}

(Playground)

Output:

Start coding in Kimber code!↓
Type commands (type <End> to stop)

Errors:

   Compiling playground v0.0.1 (/playground)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.56s
     Running `target/debug/playground`

2 posts - 2 participants

Read full topic

🏷️ Rust_feed