From b903ea3d09abf7aba9c415c37b205076b1bc1631 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 2 Mar 2026 22:12:06 +0100 Subject: Add different error styles --- oryxc/src/main.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'oryxc/src/main.rs') diff --git a/oryxc/src/main.rs b/oryxc/src/main.rs index 60733fb..d0ce286 100644 --- a/oryxc/src/main.rs +++ b/oryxc/src/main.rs @@ -37,6 +37,17 @@ impl Flags { Short('h') | Long("help") => flags.help = true, Short('l') | Long("debug-lexer") => flags.debug_lexer = true, Short('p') | Long("debug-parser") => flags.debug_parser = true, + Short('s') | Long("error-style") => { + /* TODO: Check for error (user could pass the flag twice) */ + /* TODO: Don’t unwrap */ + errors::ERROR_STYLE.set( + match parser.value()?.to_str().unwrap() { + "oneline" => errors::ErrorStyle::OneLine, + "standard" => errors::ErrorStyle::Standard, + _ => Err("invalid value for -s/--error-style")?, + }, + ); + }, Short('t') | Long("threads") => { flags.threads = parser.value()?.parse()?; if flags.threads == 0 { @@ -64,7 +75,10 @@ impl Flags { fn usage() { eprintln!( - concat!("Usage: {0} [-lp] [-t threads]\n", " {0} -h"), + concat!( + "Usage: {0} [-lp] [-s oneline|standard] [-t threads]\n", + " {0} -h", + ), errors::progname().display() ); } -- cgit v1.2.3