Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're working with files or directories, this tool simplifies common file operations with ease.
- Show content: Shows the files of the directory.
- Create file: Create a new file.
- Create directory: Create a new directory/folder.
- Append file: Append a word or a sentence in a file.
- Search: Search for a word or expression in a file.
- Replace: Replace a word or an expression in a file.
- Delete file: Delete a particular file.
- Delete directory: Delete a particular directory.
-
To use Rust File Operations, you need to have Rust installed on your system. You can install Rust from here.
-
Clone the repository using this command.
git clone https://github.com/Harikesh-14/Rust-FileOps.git
- To generate the target folder, enter the given below command
cargo build
- To run the program, use the given below rule
cargo run <file operation>
To list all the files and folders in a directory, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the directory where the project is located.
-
Run the following command:
- To search in a particular directory
cargo run show <directory_name>
- To search in the current directory
cargo run show .
To create a file in the main directory, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the directory where the project is located.
-
Run the following command:
cargo run create -a <filename>
To create a directory in the main directory, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the directory where the project is located.
-
Run the following command:
cargo run newdir -a <directory name>
To append a file in the main directory, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the directory where the project is located.
-
Run the following command:
cargo run write -a <filename>
To search for a word or expression in a file, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the directory where the project is located.
-
Run the following command:
cargo run search <word_to_search> <filename> <is_case_sensitive>
Replace
<word_to_search>
with the word or expression you want to search for,<filename>
with the name of the file to search in, and<is_case_sensitive>
withtrue
if you want the search to be case-sensitive, orfalse
otherwise.- This command searches for the word "Rust" in the file "example.txt" with case sensitivity enabled.
cargo run search Rust example.txt true
- This command searches for the word "Rust" in the file "example.txt" with case sensitivity disabled.
cargo run search Rust example.txt false
- This command searches for the word "Rust" in the file "example.txt" with case sensitivity enabled.
To replace a word or expression in a file, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the directory where the project is located.
-
Run the following command:
cargo run replace <word_to_replace> <new_word> <filename> <is_case_sensitive>
Replace
<word_to_replace>
with the word or expression you want to replace,<new_word>
with the word or expression you want to replace it with,<filename>
with the name of the file to perform the replacement in, and<is_case_sensitive>
withtrue
if you want the replacement to be case-sensitive, orfalse
otherwise.- This command replaces the word "old" with "new" in the file "example.txt" with case sensitivity enabled.
cargo run replace old example.txt true
- This command replaces the word "old" with "new" in the file "example.txt" with case sensitivity disabled.
cargo run replace old example.txt false
- This command replaces the word "old" with "new" in the file "example.txt" with case sensitivity enabled.
This addition will provide clear instructions on how to use the replace function in your Rust FileOps tool.
To delete a file, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the directory where the project is located.
-
Run the following command:
cargo run delete -d <filename>
Replace
<filename>
with the name of the file you want to delete.- This command deletes the file "example.txt" from the current directory.
cargo run delete -d example.txt
- This command deletes the file "example.txt" from the current directory.
To delete a directory, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the directory where the project is located.
-
Run the following command:
cargo run dldir -d <directory_name>
Replace
<directory_name>
with the name of the directory you want to delete.- This command deletes the directory "my_directory" from the current directory.
cargo run dldir -d my_directory
- This command deletes the directory "my_directory" from the current directory.
Rust File Operations provides a simple yet powerful way to manipulate files using the Rust programming language. Whether you need to search for specific content in a file or perform more complex file operations, Rust File Operations has you covered.
We hope you find this tool useful for your file manipulation tasks. If you have any feedback, suggestions, or encounter any issues, please feel free to open an issue on our GitHub repository.