Skip to content

A boilerplate python project that implements a CLI, logging, settings and file-based configuration loading.

License

Notifications You must be signed in to change notification settings

stfloyd/pycli-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python CLI Program Template

A boilerplate python project that implements a CLI, logging, settings and file-based configuration loading.

Quick Start

  • Enter virtual environment with pipenv shell
  • Install dependencies by running pipenv install
  • Run tool with python main.py
  • 😎 That's it!

Project Structure

  • All configuration for the program will go in config/.
    • config.json is the default configuration file.
  • app/
    • __init__.py contains 3 important methods:
      • init(args) is the initial configuration stage of the program.
      • load_config(args) is the configuration file loading stage.
      • process(args, config) is the main logic of the program.
    • logging.py defines specialized logging helper definitions.
    • settings.py defines program operating settings.
  • config/ contains program JSON configuration files.
  • tests/ contains tests for the project (pytest).
  • logs/ contains program logs (debug, error, default).
  • main.py is the main entry point of the program.

Configuration

You can define your own schema as you see fit. Just make sure to adjust the DEFAULT_CONFIG in app/settings.py.

Commands & Usage

This template uses argparse to define CLI commands.
  • -h, --help prints command and syntax help for the program.
  • -v, --verbose enables verbose output.
  • -c, --config point to a non-default configuration file.
  • --version prints program version information.
Example: python main.py --config=config/secondary.json --verbose

About

A boilerplate python project that implements a CLI, logging, settings and file-based configuration loading.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages