refactor: simplify input logic

This commit is contained in:
electria 2026-10-04 16:45:48 -07:00
commit e59f928192
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -7,14 +7,15 @@ use std::{
use tylc as lib;
fn main() -> ExitCode {
let input = match env::args().skip(1).rev().reduce(|x, a| a + &x) {
Some(s) => s,
None => {
let input = env::args()
.skip(1)
.rev()
.reduce(|x, a| a + &x)
.unwrap_or_else(|| {
let mut buf = String::new();
io::stdin().read_to_string(&mut buf).unwrap();
buf
}
};
});
match lib::formatting::pretty_eval(input, 10) {
Ok(s) => println!("{s}"),