diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2026-03-04 01:52:49 +0100 |
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2026-03-04 02:00:13 +0100 |
| commit | bba59647ed4805cdbc14bc3254acc14053846e2e (patch) | |
| tree | 61c0f8f2c3adcdd1803de485a707d1ed3cb5e986 /oryxc/src/main.rs | |
| parent | 35989b69510400cc6a28190e415687a847cd5a40 (diff) | |
Better handling of -s/--error-style
Diffstat (limited to 'oryxc/src/main.rs')
| -rw-r--r-- | oryxc/src/main.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/oryxc/src/main.rs b/oryxc/src/main.rs index 1b5577f..aa350e8 100644 --- a/oryxc/src/main.rs +++ b/oryxc/src/main.rs @@ -22,6 +22,7 @@ pub struct Flags { pub debug_parser: bool, pub help: bool, pub threads: usize, + pub error_style: errors::ErrorStyle, } impl Flags { @@ -39,15 +40,12 @@ impl Flags { 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 */ - let _ = 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")?, - }, - ); + flags.error_style = match parser.value()?.to_str().unwrap() { + "oneline" => errors::ErrorStyle::OneLine, + "standard" => errors::ErrorStyle::Standard, + s => Err(format!("{s}: invalid value for -s/--error-style"))?, + }; }, Short('t') | Long("threads") => { flags.threads = parser.value()?.parse()?; @@ -99,5 +97,6 @@ fn main() { process::exit(0); } + let _ = errors::ERROR_STYLE.set(flags.error_style); compiler::start(rest, flags); } |