Skip to main content

A collection of practical Python CLI tools

Project description

๐Ÿ“ฆ Available on PyPI

Python CLI Tools

Python 3.10+ MIT License CI Pipeline codecov PyPI version Wheel

A collection of practical, well-tested command-line utilities implemented in Python. This project demonstrates modular CLI tool development with a clean src/ layout, comprehensive testing, and easy distribution via PyPI.

Table of Contents

Features

  • Modular Design: Each tool is isolated in its own package under src/, promoting maintainability and reusability.
  • Comprehensive Testing: Unit tests with pytest ensure reliability and facilitate refactoring.
  • Console Scripts: Tools are installable as command-line scripts via pyproject.toml.
  • Minimal Dependencies: Only essential libraries are used, with requests for network operations.
  • Cross-Platform: Compatible with Windows, macOS, and Linux.
  • Open Source: Licensed under MIT, encouraging contributions and modifications.

Project Structure

python-cli-tools/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ file_organizer/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ file_organizer.py
โ”‚   โ”œโ”€โ”€ password_generator/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ password_generator.py
โ”‚   โ””โ”€โ”€ weather_cli/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ weather_cli.py
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ test_file_organizer.py
โ”‚   โ”œโ”€โ”€ test_password_generator.py
โ”‚   โ””โ”€โ”€ test_weather_cli.py
โ”œโ”€โ”€ docs/
โ”‚   โ””โ”€โ”€ usage_examples.md
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ tests.yml
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ .gitignore

Installation

Prerequisites

  • Python 3.10 or higher
  • pip for package management

Quick Install

  1. Clone the repository:

    git clone https://github.com/wrogistefan/python-cli-tools.git
    cd python-cli-tools
    
  2. Create and activate a virtual environment:

    python -m venv .venv
    # On Windows (PowerShell)
    .venv\Scripts\Activate.ps1
    # On macOS/Linux
    source .venv/bin/activate
    
  3. Install dependencies and the package in editable mode:

    pip install -r requirements.txt
    pip install -e .
    

This installs the tools as console scripts: file-organizer, password-generator, and weather-cli.

Usage

After installation, run the tools directly from the command line:

file-organizer <directory>
password-generator
weather-cli --city "New York"

Alternatively, run as Python modules:

python -m file_organizer.file_organizer <directory>
python -m password_generator.password_generator
python -m weather_cli.weather_cli --city "New York"

Tools

File Organizer

Organizes files in a specified directory into subdirectories based on their file extensions.

Usage:

file-organizer <directory>

Example:

file-organizer ./downloads

Sample Output:

Moved: report.pdf -> ./downloads/pdf
Moved: photo.jpg -> ./downloads/jpg
Moved: README -> ./downloads/no_extension

Source: src/file_organizer/file_organizer.py

Password Generator

Generates secure, customizable random passwords with options for length and character sets.

Usage:

password-generator [options]

Options:

  • -l, --length: Specify password length (default: 12)
  • --no-digits: Exclude digits
  • --no-specials: Exclude special characters

Examples:

password-generator
password-generator -l 16 --no-specials

Sample Output:

k9F3nAq2Zo1LmV7$

Source: src/password_generator/password_generator.py

Weather CLI

Fetches and displays real-time weather data for a specified location using the Open-Meteo API.

Usage:

weather-cli --city <city_name>
weather-cli --lat <latitude> --lon <longitude>

Examples:

weather-cli --city "New York"
weather-cli --lat 37.075 --lon 15.286

Sample Output:

๐Ÿ“ Location: Syracuse, Italy (37.07542, 15.28664)

๐ŸŒค๏ธ  Current Weather:
   ๐ŸŒก๏ธ  Temperature: 12.9ยฐC
   ๐Ÿ’จ  Wind Speed: 2.5 km/h
   ๐Ÿงญ  Wind Direction: 270ยฐ
   โฑ๏ธ  Observation Time: 2025-12-25T17:45

Source: src/weather_cli/weather_cli.py

For more detailed examples, see docs/usage_examples.md.

Testing

Run the test suite using pytest:

pytest

Tests are located in the tests/ directory and cover all tools to ensure functionality and prevent regressions.

Development

Building for Distribution

To build wheel and source distributions:

pip install build
python -m build

Artifacts will be created in the dist/ directory.

Code Quality

  • Use black for code formatting (configured in pyproject.toml).
  • Follow PEP 8 style guidelines.
  • Maintain high test coverage.

Adding New Tools

  1. Create a new package under src/.
  2. Implement the tool in a module with a main() function.
  3. Add console script entry in pyproject.toml.
  4. Write comprehensive tests in tests/.
  5. Update documentation.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/your-feature-name.
  3. Write tests for new functionality.
  4. Ensure all tests pass: pytest.
  5. Commit your changes: git commit -m 'Add some feature'.
  6. Push to the branch: git push origin feature/your-feature-name.
  7. Open a pull request.

Please read the contributing guidelines if available, and ensure your code adheres to the project's standards.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

ลukasz Perek

This project serves as a portfolio piece demonstrating practical CLI development, modular Python packaging, and the transition into software engineering and AI freelancing. git add README.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_cli_tools-0.2.5-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file python_cli_tools-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for python_cli_tools-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 023efcf375f8824a91330d4d698a70097b17437d5232cdd125611ab2e0fd4e1c
MD5 073818c360a05160003f396e336e2a70
BLAKE2b-256 8fb08097e984b407b7e4a5580a8838385cbc975522d30ef74efbb52689781891

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page