{"id":19041042,"url":"https://github.com/everythingme/click-config","last_synced_at":"2025-06-16T01:32:41.625Z","repository":{"id":29931085,"uuid":"33477245","full_name":"EverythingMe/click-config","owner":"EverythingMe","description":"Config parsing for click cli applications","archived":false,"fork":false,"pushed_at":"2020-03-20T14:24:40.000Z","size":18,"stargazers_count":30,"open_issues_count":2,"forks_count":6,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-23T21:37:36.855Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EverythingMe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-06T10:38:12.000Z","updated_at":"2024-09-03T04:30:09.000Z","dependencies_parsed_at":"2022-09-07T08:40:38.419Z","dependency_job_id":null,"html_url":"https://github.com/EverythingMe/click-config","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/EverythingMe/click-config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fclick-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fclick-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fclick-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fclick-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EverythingMe","download_url":"https://codeload.github.com/EverythingMe/click-config/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fclick-config/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260081438,"owners_count":22956113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T22:26:37.352Z","updated_at":"2025-06-16T01:32:41.604Z","avatar_url":"https://github.com/EverythingMe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Python config parsing helper for [click](http://click.pocoo.org)\n\n```click-config``` provides a decorator that takes a python object and overwrites its attributes with values passed into the program via command line arguments.\n\n#### NOTE: This project is unmaintained.\n\n## Usage:\n\nCreate an entry point for your project (e.g: main.py):\n```python\nfrom __future__ import print_function\nimport click\nimport click_config\n\n\nclass config(object):\n    class logger(object):\n        level = 'INFO'\n\n    class mysql(object):\n        host = 'localhost'\n\n\n@click.command()\n@click_config.wrap(module=config, sections=('logger', 'mysql'))\ndef main():\n    print('log level: {}, mysql host: {}'.format(\n        config.logger.level,\n        config.mysql.host\n    ))\n\n\nif __name__ == '__main__':\n    main()\n```\n\n```bash\n$ python main.py --help\nUsage: main.py [OPTIONS]\n\nOptions:\n  --conf-mysql TEXT\n  --conf-logger TEXT\n  -c, --conf PATH\n  --help              Show this message and exit.\n```\n\nThe ```click_config.wrap``` decorator creates options for each one of the ```sections```:\n```bash\n$ python main.py --conf-logger \"level: WARN\"\nlog level: WARN, mysql host: localhost\n```\n\nYou can also use the ```--conf``` option to pass in yaml files:\n```bash\n$ echo \"logger: {level: WARN}\" \u003e /tmp/logger.yaml\n$ echo \"mysql: {host: remotehost}\" \u003e /tmp/mysql.yaml\n$ python main.py --conf /tmp/mysql.yaml --conf /tmp/logger.yaml\nlog level: WARN, mysql host: remotehost\n```\n\nYou can also use conf.d style configurations and pass ```--conf``` to recursively traverse a directory\n```bash\n$ echo \"logger: {level: WARN}\" \u003e /tmp/conf.d/logger.yaml\n$ echo \"mysql: {host: remotehost}\" \u003e /tmp/conf.d/mysql.yaml\n$ python main.py --conf /tmp/conf.d\nlog level: WARN, mysql host: remotehost\n```\n\nFinally, you can use the ```CONF``` environment variable as an alternative to the ```--conf``` command line option, use ':' as the delimiter:\n```bash\n$ echo \"logger: {level: WARN}\" \u003e /tmp/logger.yaml\n$ echo \"mysql: {host: remotehost}\" \u003e /tmp/mysql.yaml\n$ CONF=/tmp/mysql.yaml:/tmp/logger.yaml python main.py\nlog level: WARN, mysql host: remotehost\n```\n\n\n## inotify support (ALPHA):\n\n```click-config``` also supports watching files using ```inotify``` and ```tornado```.\nTo enable this feature you must install ```click-config``` with the ```inotify``` extra.\n```bash\n$ pip install 'click-config[inotify]'\n```\nTo watch files simply invoke ```click_config.wrap()``` with ```watch=True```\nThe configuration module will automatically be updated when the files change.\nWhen using this feature, the wrapped function will receive a ```watcher``` parameter which you can use to listen for key change events.\n\n```python\ndef on_key_change(section, key, value):\n    pass\n\n@click.command()\n@click_config.wrap(module=config, sections=('logger', 'mysql'), watch=True)\ndef main(watcher):\n    watcher.add_listener(('mysql', 'host'), on_key_change)  # watch a specific key\n    watcher.add_listener(('mysql', ), on_key_change)        # watch all keys in the 'mysql' section\n    watcher.add_listener(watcher.ALL, on_key_change)        # watch all keys in all sections\n    watcher.io_loop.start()\n```\n\n\n## NOTES:\n\n* ```click-config``` will parse any file ending with ```.conf```, ```.ini```, ```.yml``` or ```.yaml```.\n* ```.conf``` and ```.ini``` are loaded with ConfigParser\n* ```.yml``` and ```.yaml``` are loaded with a yaml parser\n* A configuration object must be modeled in a 2 level hierarchy like an ```.ini``` file, where keys are stored under a section.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverythingme%2Fclick-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feverythingme%2Fclick-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverythingme%2Fclick-config/lists"}