generated from PlexSheep/rs-base
Compare commits
No commits in common. "03a2243a3e1a6b8ebbc6bd5362ca8117b3179648" and "c5790f9d7901f30e7c58b4df0896adde27c5d108" have entirely different histories.
03a2243a3e
...
c5790f9d79
1 changed files with 5 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
//! # numf
|
||||||
|
//!
|
||||||
|
//! This binary should just take any amount of numbers and print them out formatted to some other
|
||||||
|
//! system.
|
||||||
|
|
||||||
use std::io::{IsTerminal, Read};
|
use std::io::{IsTerminal, Read};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
|
@ -12,7 +17,6 @@ fn main() -> anyhow::Result<()> {
|
||||||
let mut options = FormatOptions::parse();
|
let mut options = FormatOptions::parse();
|
||||||
let mut stdin_nums = Vec::new();
|
let mut stdin_nums = Vec::new();
|
||||||
let stdin = std::io::stdin();
|
let stdin = std::io::stdin();
|
||||||
// only accept numbers from stdin if the stdin is not an interactive terminal
|
|
||||||
if !stdin.is_terminal() {
|
if !stdin.is_terminal() {
|
||||||
match stdin.lock().read_to_end(&mut stdin_nums) {
|
match stdin.lock().read_to_end(&mut stdin_nums) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
@ -45,7 +49,6 @@ fn main() -> anyhow::Result<()> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// add random numbers to the number list, according to how many are requested
|
|
||||||
if options.rand() > 0 {
|
if options.rand() > 0 {
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
let mut rand = rand::rngs::OsRng;
|
let mut rand = rand::rngs::OsRng;
|
||||||
|
@ -54,7 +57,6 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// exit with error if no numbers are to be formatted
|
|
||||||
if options.numbers().is_empty() {
|
if options.numbers().is_empty() {
|
||||||
eprintln!("{}", FormatOptions::command().render_usage());
|
eprintln!("{}", FormatOptions::command().render_usage());
|
||||||
eprintln!("no numbers have been provided");
|
eprintln!("no numbers have been provided");
|
||||||
|
|
Reference in a new issue