generated from PlexSheep/rs-base
Compare commits
No commits in common. "706c06ce6f31baeee6769a56ffc8fc41f3823ea3" and "1f4818ff98f038adfa6fda6bad5ffc4cb1db2f87" have entirely different histories.
706c06ce6f
...
1f4818ff98
1 changed files with 1 additions and 29 deletions
30
src/main.rs
30
src/main.rs
|
@ -3,41 +3,13 @@
|
||||||
//! This binary should just take any amount of numbers and print them out formatted to some other
|
//! This binary should just take any amount of numbers and print them out formatted to some other
|
||||||
//! system.
|
//! system.
|
||||||
|
|
||||||
use std::io::Read;
|
|
||||||
use std::process::exit;
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
mod format;
|
mod format;
|
||||||
use format::*;
|
use format::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// try to read from stdin first, appending the numbers we read to the FormatOptions
|
let options = FormatOptions::parse();
|
||||||
let mut args: Vec<String> = std::env::args_os()
|
|
||||||
.map(|x| x.into_string().unwrap())
|
|
||||||
.collect();
|
|
||||||
let mut stdin_nums = Vec::new();
|
|
||||||
match std::io::stdin().lock().read_to_end(&mut stdin_nums) {
|
|
||||||
Ok(_) => {
|
|
||||||
let whole: String = match String::from_utf8(stdin_nums) {
|
|
||||||
Ok(r) => r,
|
|
||||||
Err(e) => {
|
|
||||||
eprintln!("stdin for this program only accepts text: {e:#?}");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let split = whole.split_whitespace();
|
|
||||||
for s in split {
|
|
||||||
args.push(s.to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
eprintln!("could not read from stdin: {e:#?}");
|
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let options = FormatOptions::parse_from(args);
|
|
||||||
|
|
||||||
let mut out: Vec<String> = Vec::new();
|
let mut out: Vec<String> = Vec::new();
|
||||||
|
|
||||||
|
|
Reference in a new issue