Skip to content

Commit

Permalink
project files
Browse files Browse the repository at this point in the history
  • Loading branch information
tralwdwdd committed Sep 29, 2024
1 parent 6aba680 commit 9b75dcf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "cat"
version = "0.1.0"
edition = "2021"

[dependencies]
20 changes: 20 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::fs;
use std::env;

fn main(){
let file = env::args().nth(1).unwrap_or_else(|| {
eprint!("Error: No file specified");
std::process::exit(1);
});
match fs::read_to_string(file) {
Ok(contents) => {
// Successfully read the file
print!("{}", contents);
}
Err(err) => {
// Handle the error
eprint!("Error reading file: {}", err);
std::process::exit(1);
}
}
}

0 comments on commit 9b75dcf

Please sign in to comment.