RustCat is an enhanced reimplementation of the Unix cat command, offering advanced features for modern use cases. It is designed to provide powerful capabilities for file concatenation, line numbering, file search, and more, while maintaining a user-friendly command-line interface. Currently, RustCat works with only files and does not work with standard input. RustCat reimplements most of the original cat features and adds additional features.
- Search Functionality: Allows users to search and highlight specific terms within a file.
- Syntax Highlighting: Utilizes the
syntectlibrary for accurate syntax highlighting in various programming languages.
To install RustCat, ensure Rust is installed on your system. Then use cargo to install:
cargo install rustcat
RustCat includes numerous command-line options for flexible file processing:
- Display File:
rustcat file- Standard file display. - Concatenate Files:
rustcat file1 file2...- Concatenate and display multiple files. - Number Non-Blank Lines:
rustcat -b fileorrustcat --number-nonblank file- Number non-blank lines only. This overrides -n - Display Non-Printing Characters:
rustcat -e fileorrustcat --show-nonprinting-and-ends file- Show non-printing characters and$at line end. It is the same as -vE.rustcat -t fileorrustcat --show-nonprinting-and-tabs file- Display non-printing characters with tabs as^I. This is the same as -vT.rustcat -v fileorrustcat --show-nonprinting file- Display control characters and non-ASCII characters in a visible format.
- Show Ends/Tabs:
rustcat -E fileorrustcat --show-ends file- Display$at the end of each line.rustcat -T fileorrustcat --show-tabs file- Show TAB characters as^I.
- Number All Lines:
rustcat -n fileorrustcat --number file- Number all output lines. - Squeeze Blank Lines:
rustcat -s fileorrustcat --squeeze-blank file- Suppress multiple consecutive empty lines. - Show All:
ruscat -A fileorrustcat --show-all fileis the same as -vET. - Syntax Highlighting:
ruscat -x fileorrustcat --highlight filename.rs- Syntax highlighting (the syntax highlight is for .rs extensions but the highlighting also works for .py) - Search in File:
rustcat -f "search term" fileorrustcat --search "search term" file- Highlight a specified search term within a file. - Help and Version Info:
rustcat --help- Display detailed usage instructions.rustcat --version- Show the current version of RustCat.
RustCat undergoes thorough integration testing, comparing its output with the Unix cat command to ensure feature compatibility and correctness.
The next steps for this project would be the following:
- Display input from standard input in addition to files.
- Additional integration tests (search, multiple files, displaying standard input, syntax highlighting, highlighting search word)
This project was developed with the aid of ChatGPT. Here are some of the ChatGPT links:
- https://chat.openai.com/share/d35634d7-16e1-433d-9875-6510562d052b
- https://chat.openai.com/share/d35634d7-16e1-433d-9875-6510562d052b
- https://chat.openai.com/share/06abcfb0-4af8-4ecb-b156-6a542f5792b1 I also utilized the manual for Unix and Linux:
- https://www.man7.org/linux/man-pages/man1/cat.1.html
- https://ss64.com/bash/cat.html
- https://www.unix.com/man-page/osx/1/cat/
- man cat in Unix and Linux.
RustCat is available under the MIT License.