mirror of
https://github.com/Noratrieb/jsonformat.git
synced 2026-01-14 14:15:03 +01:00
works
This commit is contained in:
parent
bf1155cd00
commit
d0733b1a7c
4 changed files with 181 additions and 3 deletions
23
src/main.rs
23
src/main.rs
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue