This commit is contained in:
nora 2021-07-17 20:42:02 +02:00
parent bf1155cd00
commit d0733b1a7c
4 changed files with 181 additions and 3 deletions

View file

@ -1,3 +1,22 @@
fn main() {
println!("Hello, world!");
use jsonformat::format_json;
use std::fs;
use std::io;
use std::io::Read;
fn main() -> Result<(), io::Error> {
let filename = std::env::args().skip(1).next();
let str = match filename {
Some(path) => fs::read_to_string(path)?,
None => {
let mut buf = String::new();
let stdin = std::io::stdin();
stdin.lock().read_to_string(&mut buf)?;
buf
}
};
println!("{}", format_json(&str, " "));
Ok(())
}