Skip to main content

No project description provided

Project description

click-schema-config

click-schema-config allows you to add settings from a config file. Those will be automatically pulled into your program description without having to repeat them. Comments will be used as helper text for click.

Installation

poetry add click-schema-config

or, using pip

pip install click-schema-config

Usage

Decorate your function with

@schema_from_inis(filenames=[...])

This will automatically infer the structure of your ini files and its documentation and add it to click.

Example of a config.default.ini:

testqwlj =

[test1]
; Wow, multilines
; Talk about eye candy
var1="value1"
var2: int = 2
var3 = True

[test2]
var1 = "value1" # Comment

; This is a comment
123j = None

Note that you can type values directly.

import pprint
import click
from click_schema_config import schema_from_inis


@click.command()
@schema_from_inis(filenames=["config.default.ini"])
def main(**kwargs):
    pprint.pprint(kwargs)

if __name__ == "__main__":
    main()

This will result in:

python TODO.py --help

Usage: TODO.py [OPTIONS]

Options:
  --test2.123j TEXT               This is a comment
  --test2.var1 TEXT
  --test1.var3 / --no-test1.var3
  --test1.var2 INTEGER
  --test1.var1 TEXT               Wow, multilines Talk about eye candy
  --testqwlj TEXT
  --help                          Show this message and exit.

You can of course override using the options:

python TODO.py --test2.123j hey

{'test1__var1': 'value1',
 'test1__var2': 2,
 'test1__var3': True,
 'test2__123j': 'hey',
 'test2__var1': 'value1',
 'testqwlj': None}

Rationale

[TODO]

TODO

[TODO]

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

click-schema-config-0.1.1.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

click_schema_config-0.1.1-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

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