Commit abd73ad3 authored by Moritz Sokoll's avatar Moritz Sokoll 🦀
Browse files

Inital commit

parents
Pipeline #287 canceled with stages
image: rust:1.53.0
build:
stage: build
script:
- cargo build
test:
stage: test
script:
- cargo run -- src/main.rs src/rcat.rs
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rcat"
version = "0.1.0"
dependencies = [
"stacking",
]
[[package]]
name = "stacking"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36b0a850a979c80a4f7b49222dd99e62bfa1b650b76a2536f7fd6d088fbc9be7"
[package]
name = "rcat"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
stacking = "0.2.5"
VERSION = 0.1.0
NAME = rcat
PREFIX ?= /usr/local
all: build
build:
cargo build
clean:
cargo clean
install: release
mv target/release/rcat $(PREFIX)/bin/rcat
release:
cargo build --release
use stacking::stacks::Queue;
use std::env::args;
use std::fs::read_to_string;
mod rcat;
fn main() {
let argv: Vec<String> = args().collect();
let mut files: Queue<String> = Queue::new();
for arg in &argv[1..].to_vec() {
match arg.as_str() {
"--help" | "-h" => {
println!("{}", rcat::RCAT_HELP);
}
"--version" | "-v" => {
println!("{}", rcat::RCAT_VERSION);
}
f => files.push(f.to_string()),
}
}
// read files and print them to the screen
while files.len() != 0 {
let fname: String = files.pop().unwrap();
let contents: String = match read_to_string(fname.as_str()) {
Ok(s) => s,
Err(e) => {
eprintln!("rcat: error opening file ({})", e);
String::new()
}
};
println!("{}", contents);
}
}
pub const RCAT_HELP: &str = "
rcat [options] <files>
Options:
-h,--help: print this help information and exit
-v,--version: print the version and exit
";
pub const RCAT_VERSION: &str = "rcat v0.1.0";
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment