A simple Rust command-line tool to read and display the contents of a text file like cat.
Supports UTF-8 text files only.
-
Clone the repository:
git clone https://github.com/Shaurya-Sethi/read-rs.git cd read-rs -
Install the tool globally using Cargo:
cargo install --path .This will make
read-rsavailable in your system's PATH.
Once installed, run the tool with a file path:
read-rs <FILE_PATH>For development or local testing:
cargo run -- <FILE_PATH>Or run the built binary directly:
./target/debug/read-rs <FILE_PATH>The tool automatically provides help and version information:
read-rs --help
read-rs --versionExample:
read-rs fixtures/hello.txtOutput:
Hello, world!
-
Prints the file contents to stdout.
-
Prints errors to stderr.
-
Exit codes:
0→ success1→ user error (file not found, not readable, not UTF-8, or path is a directory)2→ unexpected/internal error
- Only works with UTF-8 encoded text files.
- Binary files and non-UTF-8 text are not supported.
MIT