A simple version of UNIX Shell developed using Python and Pytest with awesome open-source technologies
Overview • Preview • Demo • Shell Commands • Technologies • File Structure • Setup • Tests • License
A simple version of UNIX Shell developed using Python programming language and Pytest framework, under a Linux environment, with several awesome open-source technologies. The shell can handle both built-in commands and executable files. It is not sophisticated as Bash or Zsh, but it performs similar functions.
The codebase is pretty organized, easier to maintain, and scalable as the project grows (if that happened) due to the clean file structure, clean code, and great documentation. This has been be done with modularity, best practices, documentation, documentation strings, type hinting, and unit testing, which made the codebase easier to debug and maintain, as well as, ensured code correctness.
Command | Description |
---|---|
ls |
Lists files and directories in the current location. |
cd |
Changes the current working directory. |
pwd |
Displays full pathname of the current working directory |
mkdir |
Creates a new directory. |
touch |
Creates an empty file or updates the timestamp of an existing file. |
clear |
Clears the terminal screen. |
date |
Displays the current date. |
time |
Displays the current time. |
ps |
Displays information about currently running processes. |
echo |
Prints text or variables to the terminal. |
pid |
Displays the shell Process ID (PID). |
ppid |
Displays the shell Parent Process ID (PPID). |
info |
Provides the project documentation. |
help |
Provides information and help about shell commands. |
exit |
Terminates the current shell session. |
Executable Files | Executes executable files located in the current directory (./ ) or the parent directory (../ ). |
This project is structured to facilitate the development and testing of various utilities. The architecture is organized into several directories and files, each serving a specific purpose. Below is a detailed breakdown of the project structure.
.
├── app.py
├── requirements.txt
├── requirements-dev.txt
├── LICENSE
├── README.md
├── .gitignore
├── utils/
├── tests/
└── .github/
app.py
file: Contains the main function which serves as the entry point of the applicationrequirements.txt
file: Lists the dependencies needed for the application to run in productionrequirements-dev.txt
file: Lists the dependencies needed for development, such as testing frameworks and lintersLICENSE
file: Specifies the terms and conditions for using and distributing the softwareREADME.md
file: Provides the project documentation.gitignore
file: Specifies intentionally untracked files that Git should ignore
utils/
directory: Contains the implementation of various utilitiestests/
directory: Contains unit tests for the modules in theutils
directory.github/
directory: Contains files and directories that customize and enhance the GitHub repository's functionality and appearance
After cloning this repository, you should following this step-by-step instructions to setup the production environment and run the application locally on your machine.
-
Update and upgrade packages.
sudo apt update && sudo apt upgrade -y
-
Install
Python 3.10
interpreter.sudo apt install python3.10
-
Install
python3.10-venv
package.sudo apt install python3.10-venv
-
Navigate to the project's root directory.
-
Create a virtual environment.
python3.10 -m venv .venv
-
Activate the virtual environment.
source .venv/bin/activate
-
Install production dependencies.
pip install -r requirements.txt
-
Make the
app.py
file executable.chmod +x app.py
-
Run the shell application.
./app.py
-
Simply close the terminal window or use the
exit
command to exit the terminal session.exit
-
Deactivate the virtual environment.
deactivate
This project uses Pytest for unit testing. Follow the steps below to run the tests.
-
Navigate to the project's root directory, and activate the virtual environment.
source .venv/bin/activate
-
Install development dependencies.
pip install -r requirements-dev.txt
-
Run Pytest with basic verbosity on details.
pytest -v
-
After the tests finished, deactivate the virtual environment.
deactivate
This project is licensed under the MIT License.