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
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
Built Distribution
Close
Hashes for click-schema-config-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 295d04a6b817d447cb1b088cc24735f936914f193e6510b5e8fb2a58be321bf2 |
|
MD5 | 4ccb3ca9cee1dee827d37f3730ce6816 |
|
BLAKE2b-256 | ec90d553942f185a6d8d0e7d2956d839c0aa3a53639a50f0979da5b856e86851 |
Close
Hashes for click_schema_config-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9520bba9246506fcaa6731f1fb9004ae4df87811be973f729f754a4cbaa96d66 |
|
MD5 | 0e8cfb3084c4a387e2bb910152b21a0b |
|
BLAKE2b-256 | f5333a7239a81af01a8e7e669427021d0f4e5d01b51edb362a0867b5768a0fc4 |