Before you begin, ensure you have the following installed:
- Python 3.6 or higher
- pip for Python package management
- Access to a terminal or command line interface
- Before installing the project, ensure you have setuptools installed, as it is required for the installation process.
pip install setuptools
git clone https://github.com/akashsahu006/inito-task.git
cd inito-task
Navigate to the directory containing setup.py and run the following command to install the package and its dependencies:
pip install .
python main.py
python test.py
- To create a new directory:
mkdir directoryname
- To change directories use following options:
cd directoryname
cd ~
cd /
cd ..
- To list contents in a directory:
ls
- To search within files: grep "pattern" filename.txt
grep -i pattern filename
grep -c pattern filename
grep -n pattern filename
grep -v pattern filename
- To display the contents of a file:
cat filename
cat -n filename
- To create a new file:
touch filename
- To write to a file: echo "text" > filename.txt
echo "text" > filename
- To move or rename a file/directory:
mv source target
- To copy a file or directory: cp source target
cp source target
- To remove a file or directory:
rm filename
mkdir:
It is implemented in function - create_folder. The os.makedirs("file_name") is used to create new folder. Errors like "file exists" or "no file name given" errors are checked.cd:
It is implemented in function - change_path. The function os.chdir(path) is used. Use cases like ".." to go to parent directory, "~" or "/" to go to root directory and absolute path are considered. Errors like "invalid path" are checked.ls:
It is implemented in function - list_directory_contents. The function os.listdir() is used. The error like invalid commands are checked.grep:
It is implemented in file grep.py. Total four variation are implemented those are:- -n -i -v -c.cat:
It is implemented in function display_file_contents. It is implemented using file.read() function. Use cases like cat filename.txt and cat -n filename.txt (Read file content with line number) is considered. Errors like "file does not exist" are checked.touch:
It is implemented in function - touch. It uses function open(filename, "x"). Cases like if file already exist is also considered.echo:
It is implemented in function - write_to_file. It uses function open(filename, "a") to write to file. Use cases like retaining previous content in existing file and writing into empty file is considered.mv:
It is implemented in function - move_file_or_directory. It uses function shutil.move(source, destination).cp:
It is implemented in function - copy_file_or_directory. It uses function shutil.copy(source, destination).rm:
It is implemented in function - remove_file_or_directory(). It uses os.remove() and os.rmdir() functions. Errors like file does not exist are accounted.
test_mkdir:
This test checks if a new directory gets created or not using mkdir command.test_mkdir_file_exists:
This test tries to create an existing directory to check if correct error message is given.test_cd:
This test checks if cd command is executed or not.test_cd_parent:
This test checks if cd command takes back to parent directory when "cd .." command is given.test_touch:
This test checks if touch command creates a new file.test_echo:
This test checks if echo command writes new text to the empty file.test_echo_append:
This test checks if the original content is maintained or lost after execution of echo command.test_rm_file:
This test checks if a file is removed or not after execution of rm command.test_rm_folder:
This test checks if a directory is removed or not after execution of rm command.test_cat:
This test checks if cat command read properly from the file or not.test_mv:
This test checks if mv command moves a file to destination folder.