kind of working
This commit is contained in:
parent
5c82375ff6
commit
1e0682390d
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -20,9 +20,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "arg-derive"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5f4f6d38dfe8c7ddd11686611d41897abd43db81e28d3cfe8903d78ee5cb06b"
|
||||
checksum = "8b3d15a8d79dbe95cc2742d3e4394789b3ac3de3909a058ae728d1fc864d1b54"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
|
6
arg/Cargo.lock
generated
6
arg/Cargo.lock
generated
@ -12,8 +12,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "arg"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae60fcba735ceff2193950be268184f45271dd9e9c0823e6d1e9c5d1070caf81"
|
||||
source = "git+https://github.com/DoumanAsh/arg.rs?branch=ignore_single_dash#14342e3fa59795345005bd21cd5f86a437bc0b10"
|
||||
dependencies = [
|
||||
"arg-derive",
|
||||
]
|
||||
@ -21,8 +20,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "arg-derive"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5f4f6d38dfe8c7ddd11686611d41897abd43db81e28d3cfe8903d78ee5cb06b"
|
||||
source = "git+https://github.com/DoumanAsh/arg.rs?branch=ignore_single_dash#14342e3fa59795345005bd21cd5f86a437bc0b10"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
|
25
src/cat.rs
25
src/cat.rs
@ -20,8 +20,8 @@
|
||||
use std::env;
|
||||
use std::fs::{File, read_to_string};
|
||||
use std::io;
|
||||
use std::io::{ BufRead, Write };
|
||||
use std::os::unix::io::FromRawFd;
|
||||
use std::io::{ Read, Write };
|
||||
use std::str;
|
||||
|
||||
use arg::Args;
|
||||
|
||||
@ -51,15 +51,18 @@ fn main() -> ExitCode {
|
||||
|
||||
for path in args.paths {
|
||||
if path == "-" {
|
||||
loop {
|
||||
match io::stdin().lock().read_line(&mut output) {
|
||||
Ok(EOF) => if EOF == 0 { break },
|
||||
Err(_) => {
|
||||
eprintln!("Usage: {} [options...] [files...]", &argv0);
|
||||
return ExitCode::Usage;
|
||||
},
|
||||
};
|
||||
}
|
||||
let mut bytes: Vec<u8> = Vec::new();
|
||||
match io::stdin().lock().read_to_end(&mut bytes) {
|
||||
Ok(EOF) => {
|
||||
for byte in &bytes {
|
||||
output.push_str(str::from_utf8(&[byte.to_owned()]).unwrap());
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
eprintln!("Usage: {} [options...] [files...]", &argv0);
|
||||
return ExitCode::Usage;
|
||||
},
|
||||
};
|
||||
} else {
|
||||
match read_to_string(&path) {
|
||||
Ok(contents) => { output.push_str(&contents) },
|
||||
|
Reference in New Issue
Block a user