yac
/
coreutils
Archived
2
0
Fork 0
This repository has been archived on 2024-01-01. You can view files and clone it, but cannot push or open issues or pull requests.
coreutils/src/cut.rs

33 lines
759 B
Rust

// Copyright (c) 2022 silt <silt@tebibyte.media>
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::env;
use std::fs::File;
use std::io::{BufReader, BufRead, Write, stdin};
fn main() -> Result<(), Box<dyn std::error::Error>>{
let mut args: Vec<String> = env::args().skip(1).collect();
println!("Args: {:#?}", args);
let mut delim = '\t';
let mut field = 1;
let mut file = stdin();
match args.first().unwrap().as_str() {
mode if ["-b", "-c", "-f"].iter().any(|&s| s == mode) => {
let list = args.get(1).unwrap();
if !list.chars().all(|s| "0123456789-, ".contains(s)) {
std::process::exit(1);
}
}
_ => { std::process::exit(1) }
}
Ok(())
}