Archived
2
0

kind of working

This commit is contained in:
Emma Tebibyte 2022-12-13 22:43:40 -05:00
parent 5c82375ff6
commit 1e0682390d
3 changed files with 18 additions and 17 deletions

4
Cargo.lock generated
View File

@ -20,9 +20,9 @@ dependencies = [
[[package]] [[package]]
name = "arg-derive" name = "arg-derive"
version = "0.3.4" version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5f4f6d38dfe8c7ddd11686611d41897abd43db81e28d3cfe8903d78ee5cb06b" checksum = "8b3d15a8d79dbe95cc2742d3e4394789b3ac3de3909a058ae728d1fc864d1b54"
dependencies = [ dependencies = [
"quote", "quote",
"syn", "syn",

6
arg/Cargo.lock generated
View File

@ -12,8 +12,7 @@ dependencies = [
[[package]] [[package]]
name = "arg" name = "arg"
version = "0.3.1" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/DoumanAsh/arg.rs?branch=ignore_single_dash#14342e3fa59795345005bd21cd5f86a437bc0b10"
checksum = "ae60fcba735ceff2193950be268184f45271dd9e9c0823e6d1e9c5d1070caf81"
dependencies = [ dependencies = [
"arg-derive", "arg-derive",
] ]
@ -21,8 +20,7 @@ dependencies = [
[[package]] [[package]]
name = "arg-derive" name = "arg-derive"
version = "0.3.4" version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/DoumanAsh/arg.rs?branch=ignore_single_dash#14342e3fa59795345005bd21cd5f86a437bc0b10"
checksum = "f5f4f6d38dfe8c7ddd11686611d41897abd43db81e28d3cfe8903d78ee5cb06b"
dependencies = [ dependencies = [
"quote", "quote",
"syn", "syn",

View File

@ -20,8 +20,8 @@
use std::env; use std::env;
use std::fs::{File, read_to_string}; use std::fs::{File, read_to_string};
use std::io; use std::io;
use std::io::{ BufRead, Write }; use std::io::{ Read, Write };
use std::os::unix::io::FromRawFd; use std::str;
use arg::Args; use arg::Args;
@ -51,15 +51,18 @@ fn main() -> ExitCode {
for path in args.paths { for path in args.paths {
if path == "-" { if path == "-" {
loop { let mut bytes: Vec<u8> = Vec::new();
match io::stdin().lock().read_line(&mut output) { match io::stdin().lock().read_to_end(&mut bytes) {
Ok(EOF) => if EOF == 0 { break }, Ok(EOF) => {
Err(_) => { for byte in &bytes {
eprintln!("Usage: {} [options...] [files...]", &argv0); output.push_str(str::from_utf8(&[byte.to_owned()]).unwrap());
return ExitCode::Usage; }
}, },
}; Err(_) => {
} eprintln!("Usage: {} [options...] [files...]", &argv0);
return ExitCode::Usage;
},
};
} else { } else {
match read_to_string(&path) { match read_to_string(&path) {
Ok(contents) => { output.push_str(&contents) }, Ok(contents) => { output.push_str(&contents) },