Skip to main content

Do CLI applications easily.

Project description

climy

Do CLI applications easily.

Instalation

$ pip install climy

Basic Usage

from climy import Application, Option, Command


def env_handler(comm: Command):
    print('do every thing with env')
    print(comm)
    print(comm.vars)

    
env_command = Command(
    name='env',
    description='Create a perfect environ to application',
    handler=env_handler
)

app = Application(
    name='acme',
    title='ACME App',
    description='A teste application',
    version='0.1.0',
    option_default_separator=Option.Separators.EQUAL
)
app.add_command(env_command)
app.add_option('host', 'The server allow host IP number.', short='t', var_type='str')
app.add_option('port', 'Service port.', short='p', var_type='int')
app.add_option('path', 'Execution code path.', var_type='str', var_name='path')
app.run()
$ acmesrv --help
ACME App (version 0.1.0)

Usage:
  acme <command> [options] [arguments]

Options:
  -h, --help                Print this help.
  -t, --host=[HOST]         The server allow host IP number.
  -p, --port=[PORT]         Service port.
  --path=[PATH]             Execution code path.

Commands:
  env                       Create a perfect environ to application

Components

Tables

To print tables quickly, you just need to define a column list with the column title, size and align. Then, preparate a data tuple list with the values in the same columns orders. Below, an example how to print tables.

from climy.console import ctable


columns = ['ID:10>', 'Name:50', 'Birth:15^', 'Weight:10>', 'Hight:10']
data = [
    (1, 'Mark White', '26/12/1977', 1.75, 80.0),
    (2, 'Eva Wood', '30/11/1983', 1.59, 50.0),
    (3, 'John Apple', '26/06/1917', 1.20, 30.0),
    (4, 'Linda Jansen', '09/05/1961', 1.63, 61.0)
]
ctable(data, columns=columns)

And the results:

┌──────────┬──────────────────────────────────────────────────┬───────────────┬──────────┬──────────┐
│       ID │ Name                                             │     Birth     │   Weight │ Hight    │
├──────────┼──────────────────────────────────────────────────┼───────────────┼──────────┼──────────┤
│        1 │ Mark White                                       │   26/12/1977  │     1.75 │ 80.0     │
│        2 │ Eva Wood                                         │   30/11/1983  │     1.59 │ 50.0     │
│        3 │ John Apple                                       │   26/06/1917  │      1.2 │ 30.0     │
│        4 │ Linda Jansen                                     │   09/05/1961  │     1.63 │ 61.0     │
└──────────┴──────────────────────────────────────────────────┴───────────────┴──────────┴──────────┘

Progress Bar

You can print progresses bars by using cprogress function.

from climy.console import cprogress


cprogress(size=50, max=300.0, value=20.0, color='green')

# ━━━───────────────────────────────────────────────

Project details


Download files

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

Source Distribution

climy-0.2.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

climy-0.2.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file climy-0.2.1.tar.gz.

File metadata

  • Download URL: climy-0.2.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.19.0-45-generic

File hashes

Hashes for climy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 41fbf9d44e571fb3e2c9a907344a0264d7d290834917254170b91b4f42442543
MD5 de80eb2a375d5960ee9686d378eb9dbf
BLAKE2b-256 5a56a2d1e86a53141c3fdeacafe59df56f497c9ff7d6d49ebfece03c4f53aa0f

See more details on using hashes here.

File details

Details for the file climy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: climy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.19.0-45-generic

File hashes

Hashes for climy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e423ee503edbdc08fe58aec5bb0ce7cd3b0e5ce78f171c11213030583ab4f8c1
MD5 4ba1e7e0f8ead55bf4426044357721e4
BLAKE2b-256 575f50d326077cc31bdeb49cfc3651b2c90ed217cea2fc5d873bdbc09947ccec

See more details on using hashes here.

Supported by

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