mohammadjarabah681 / unix-shell-with-python

A simple version of UNIX Shell developed using Python and Pytest with awesome open-source technologies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UNIX Shell

A simple version of UNIX Shell developed using Python and Pytest with awesome open-source technologies
OverviewPreviewDemoShell CommandsTechnologiesFile StructureSetupTestsLicense

Overview

A simple version of UNIX Shell developed using Python language and Pytest testing framework under the 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.

Preview

UNIX Shell Project Preview

Demo

UNIX Shell Project Demo

Shell Commands

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 (../).

Technologies

File Structure

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.

File Structure Contents

.
├── app.py
├── requirements.txt
├── requirements-dev.txt
├── LICENSE
├── README.md
├── .gitignore
├── src/
├── tests/
└── .github/

Files Detailed Breakdown

  • app.py file: Contains the main function which serves as the entry point of the application
  • requirements.txt file: Lists the dependencies needed for the application to run in production
  • requirements-dev.txt file: Lists the dependencies needed for development, such as testing frameworks and linters
  • LICENSE file: Specifies the terms and conditions for using and distributing the software
  • README.md file: Provides the project documentation
  • .gitignore file: Specifies intentionally untracked files that Git should ignore

Directories Detailed Breakdown

  • src/ directory: Contains the implementation of various utilities
  • tests/ directory: Contains unit tests for the modules in the src directory
  • .github/ directory: Contains files and directories that customize and enhance the GitHub repository's functionality and appearance

Setup

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.

I. Prerequisites

  1. You need an UNIX-like environment to run this project (e.g. Linux, macOS, or Windows Subsystem for Linux (WSL)).

  2. Update and upgrade packages (for Debian/Ubuntu users).

    sudo apt update && sudo apt upgrade -y
  3. Install Python 3.10 interpreter.

    sudo apt install python3.10
  4. If you are Debian/Ubuntu user, you need to install python3.10-venv package.

    sudo apt install python3.10-venv

II. Creating Virtual Environment

  1. Navigate to the project's root directory.

  2. Create a virtual environment.

    python3.10 -m venv .venv
  3. Activate the virtual environment.

    source .venv/bin/activate
  4. Install production dependencies.

    pip install -r requirements.txt

III. Running Shell Application

  1. Make the app.py file executable.

    chmod +x app.py
  2. Run the shell application (.venv must be activated).

    ./app.py

IV. Exiting Shell Application

  1. Simply close the terminal window or use the exit command to exit the terminal session.

    exit
  2. Deactivate the virtual environment.

    deactivate

Tests

This project uses Pytest for unit testing. Follow the steps below to run the tests.

  1. Navigate to the project's root directory, and activate the virtual environment.

    source .venv/bin/activate
  2. Install development dependencies.

    pip install -r requirements-dev.txt
  3. Run Pytest with basic verbosity on details.

    pytest -v
  4. After the tests finished, deactivate the virtual environment.

    deactivate

License

This project is licensed under the MIT License.

About

A simple version of UNIX Shell developed using Python and Pytest with awesome open-source technologies.

License:MIT License


Languages

Language:Python 100.0%