Skip to main content

Devkit for quickly building CLI tools with Python

Project description

TinyScript Tweet

Make a CLI tool with very few lines of code.

PyPi Read The Docs Build Status Coverage Status Python Versions Known Vulnerabilities License

This library is aimed to provide useful features and helpers in order to shorten the number of required lines of code for writing simple and nice-looking command-line interface tools. It is based on argparse and is considered a development kit, on the contrary of popular frameworks like cement, click or docopt, as it is not aimed to reinvent the wheel in yet another paradigm.

pip install tinyscript

Philosophy

This library is built with the DRY (Don't Repeat Yourself) and KISS (Keep It Stupid Simple) philosophies in mind ; the whole machinery of Tinyscript holds in its star import (from tinyscript import *) and its initialization (with the initialize function).

It is aimed to shorten required code by setting a few things while loaded:

  • a proxy parser (coming from the star import) collects arguments definitions and formats help at initialization, preventing from rewriting the whole bunch of code needed to declare an ArgumentParser (and define its epilog, and so forth)
  • a main (colored) logger is preconfigured and can be tuned through two constants so that we don't care for writing a bunch of code needed to configure logging
  • preimports (while a bit anti-Pythonic, we confess) of common libraries also reduces the quantity of code required
  • among these, some modules are enhanced with new functions and classes that are not natively foreseen

Leveraging this allows to create very short scripts with only the real code that matters, reducing the code to be rewritten to create efficient, nice-looking and sophisticated CLI tools.

Note that, while star imports should be avoided according to Python's style guide (see PEP8), it is deliberately extensively used and covering a huge scope in order to shorten code length. This "anti-pattern" pays off after creating a few tools, when we can realize it shortens parts of the code that are often repeated from a tool to another (e.g. for shaping tool's help message).

Usage

It is designed to be as simple and straightforward to use as possible. In order to learn and use it, you only need your browser (for consulting the documentation), a text editor and a good Python Interpreter (e.g. IDLE) for using auto-completion or an IDE like PyCharm to get helpers suggested.

The point is that you will use:

  • features, enabled by setting flags in the "master" function called ìnitialize
  • helpers, grouped under the "master" submodule called ts
  • reporting objects from the global scope

Please see the example tools herebelow for examples of usage of features, helpers and reporting.

Quick Start

Create from template

Edit source

Run your tool

Example tools

Security

Utils

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

tinyscript-1.27.4.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

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

tinyscript-1.27.4-py3-none-any.whl (166.5 kB view details)

Uploaded Python 3

File details

Details for the file tinyscript-1.27.4.tar.gz.

File metadata

  • Download URL: tinyscript-1.27.4.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for tinyscript-1.27.4.tar.gz
Algorithm Hash digest
SHA256 35a5f118d6d7de1f8a1a83e33d9f074df76f3cfe3dfb626c3773caf5ccaf3667
MD5 43c50bfdf3330de0c1553a600fcba1ff
BLAKE2b-256 6cfd051dc9490f68c972f9ccd4143db491d1e62bb2632bf22d1a09bea557acb3

See more details on using hashes here.

File details

Details for the file tinyscript-1.27.4-py3-none-any.whl.

File metadata

  • Download URL: tinyscript-1.27.4-py3-none-any.whl
  • Upload date:
  • Size: 166.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for tinyscript-1.27.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1914a84a1fa19a2e70f40a9b11cd7c731bd83684392d95fbfd4a88a4bb652018
MD5 2b1e6adeff40c559505411d2d66c0043
BLAKE2b-256 8518dc4c9e2f09e0f16146e796ad23be9b62c699db1615aae71f8707a7a0156b

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