38 lines
754 B
Rust
38 lines
754 B
Rust
// Copyright (c) 2022 Emma Tebibyte
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
use std::fs::read_to_string;
|
|
use std::io::{stdout, Write};
|
|
use std::env;
|
|
use std::process;
|
|
|
|
fn main() {
|
|
let args: Vec<String> = env::args().skip(1).collect();
|
|
let mut opts = Vec::new();
|
|
|
|
for arg in &args {
|
|
if arg.starts_with("-") {
|
|
opts.push(arg);
|
|
}
|
|
}
|
|
|
|
if opts.is_empty() == false {
|
|
for option in opts {
|
|
match option.as_str() {
|
|
// Write bytes from the input file to the standard output without
|
|
// delay as each is read.
|
|
"-u" => {},
|
|
|
|
_ => process::exit(1),
|
|
};
|
|
}
|
|
}
|
|
else {
|
|
for path in args {
|
|
print!("{}", read_to_string(path).unwrap());
|
|
}
|
|
}
|
|
|
|
stdout().flush().unwrap();
|
|
}
|