Skip to content

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.

Notifications You must be signed in to change notification settings

Harikesh-14/Rust-FileOps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust FileOps

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.

Features

  • 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.

How to Use

  1. To use Rust File Operations, you need to have Rust installed on your system. You can install Rust from here.

  2. Clone the repository using this command.

  git clone https://github.com/Harikesh-14/Rust-FileOps.git
  1. To generate the target folder, enter the given below command
  cargo build
  1. To run the program, use the given below rule
  cargo run <file operation>

Show content

To list all the files and folders in a directory, follow these steps:

  1. Open a terminal or command prompt.

  2. Navigate to the directory where the project is located.

  3. Run the following command:

    For example:

    1. To search in a particular directory
    cargo run show <directory_name>
    1. To search in the current directory
    cargo run show .

Create a file

To create a file in the main directory, follow these steps:

  1. Open a terminal or command prompt.

  2. Navigate to the directory where the project is located.

  3. Run the following command:

    cargo run create -a <filename>

Create a directory

To create a directory in the main directory, follow these steps:

  1. Open a terminal or command prompt.

  2. Navigate to the directory where the project is located.

  3. Run the following command:

    cargo run newdir -a <directory name>

Appending in a file

To append a file in the main directory, follow these steps:

  1. Open a terminal or command prompt.

  2. Navigate to the directory where the project is located.

  3. Run the following command:

    cargo run write -a <filename>

Search Operation

To search for a word or expression in a file, follow these steps:

  1. Open a terminal or command prompt.

  2. Navigate to the directory where the project is located.

  3. 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> with true if you want the search to be case-sensitive, or false otherwise.

    For example:

    • 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

Replace Operation

To replace a word or expression in a file, follow these steps:

  1. Open a terminal or command prompt.

  2. Navigate to the directory where the project is located.

  3. 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> with true if you want the replacement to be case-sensitive, or false otherwise.

    For example:

    • 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 addition will provide clear instructions on how to use the replace function in your Rust FileOps tool.

Delete a file

To delete a file, follow these steps:

  1. Open a terminal or command prompt.

  2. Navigate to the directory where the project is located.

  3. Run the following command:

    cargo run delete -d <filename>

    Replace <filename> with the name of the file you want to delete.

    For example:

    • This command deletes the file "example.txt" from the current directory.
      cargo run delete -d example.txt

Delete Directory Operation

To delete a directory, follow these steps:

  1. Open a terminal or command prompt.

  2. Navigate to the directory where the project is located.

  3. Run the following command:

    cargo run dldir -d <directory_name>

    Replace <directory_name> with the name of the directory you want to delete.

    For example:

    • This command deletes the directory "my_directory" from the current directory.
      cargo run dldir -d my_directory

Conclusion

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.

Happy file handling with Rust ❤️


About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages