{"id":25676526,"url":"https://github.com/phha/click_config_file","last_synced_at":"2025-04-23T14:04:06.926Z","repository":{"id":28464776,"uuid":"116679402","full_name":"phha/click_config_file","owner":"phha","description":"Configuration file support for Click applications","archived":false,"fork":false,"pushed_at":"2023-03-22T09:17:48.000Z","size":172,"stargazers_count":42,"open_issues_count":13,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T13:39:06.381Z","etag":null,"topics":["cli","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phha.png","metadata":{"files":{"readme":"README.rst","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-08T13:20:55.000Z","updated_at":"2025-01-14T06:05:11.000Z","dependencies_parsed_at":"2024-06-18T18:16:03.066Z","dependency_job_id":"9e59c6d6-a982-4f8a-aaf9-d0514d420ad5","html_url":"https://github.com/phha/click_config_file","commit_stats":{"total_commits":83,"total_committers":5,"mean_commits":16.6,"dds":0.3975903614457831,"last_synced_commit":"0d1940fc3dcd6e2c254798a33aee074c05a90de3"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phha%2Fclick_config_file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phha%2Fclick_config_file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phha%2Fclick_config_file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phha%2Fclick_config_file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phha","download_url":"https://codeload.github.com/phha/click_config_file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240495394,"owners_count":19810602,"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":["cli","python"],"created_at":"2025-02-24T14:34:46.121Z","updated_at":"2025-02-24T14:34:46.718Z","avatar_url":"https://github.com/phha.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Click config file\n=================\n\nEasily add configuration file support to your\n`Click \u003chttp://click.pocoo.org/5/\u003e`_ applications by adding a single\nno-arguments decorator.\n\n.. image:: https://img.shields.io/pypi/v/click-config-file.svg?style=flat-square\n    :target: https://pypi.org/project/click-config-file/\n.. image:: https://img.shields.io/conda/vn/conda-forge/click-config-file.svg?style=flat-square\n    :target: https://anaconda.org/conda-forge/click-config-file\n.. image:: https://img.shields.io/travis/phha/click_config_file/master.svg?style=flat-square\n    :target: https://travis-ci.org/phha/click_config_file\n.. image:: https://img.shields.io/codacy/grade/a5f6262609314683bf2b2bc546bdaffe/master.svg?style=flat-square\n    :target: https://www.codacy.com/app/phha/click_config_file\n\nBasic usage\n-----------\n\nclick-config-file is designed to be a usable by simply adding the\nappropriate decorator to your command without having to supply any\nmandatory arguments. It comes with a set of sensible defaults that\nshould just work for most cases.\n\nGiven this application:\n\n.. code-block:: python\n\n    @click.command()\n    @click.option('--name', default='World', help='Who to greet.')\n    @click_config_file.configuration_option()\n    def hello(name):\n        click.echo('Hello {}!'.format(name))\n\nRunning ``hello --help`` will give you this::\n\n    Usage: hello [OPTIONS]\n\n    Options:\n      --name TEXT    Who to greet.\n      --config PATH  Read configuration from PATH.\n      --help         Show this message and exit.\n\nIf the configuration file does not exist, running ``hello`` will do what\nyou expect::\n\n    Hello World!\n\nWith this configuration file::\n\n    name=\"Universe\"\n\nCalling ``hello`` will also do what you expect::\n\n    Hello Universe!\n\nCalling ``hello --name Multiverse`` will override the configuration file\nsetting, as it should::\n\n    Hello Multiverse!\n\nThe default name for the configuration file option is ``--config``.\n\nCommand line and environment options will override the configuration\nfile options. Configuration file options override default options. So\nthe resolution order for a given option is: CLI \u003e Environment \u003e\nConfiguration file \u003e Default.\n\nOptions\n-------\n\nAlthough ``configuration_option`` is designed to work without any mandatory\narguments, some optional parameters are supported:\n\n``implicit``\n  Default: ``True``\n\n  By default ``configuration_option`` will look for a configuration file\n  even if no value for the configuration option was provided either via\n  a CLI argument or an environment variable. In this case the value will\n  be set implicitly from ``cmd_name`` and ``config_file_name`` as\n  described below.\n\n  If set to ``False`` the configuration file settings will only be applied\n  when a configuration file argument is provided.\n\n``cmd_name``\n  Default: ``ctx.info_name``\n\n  The name of the decorated command. When implicitly creating a\n  configuration file argument, the application directory containing the\n  configuration file is resolved by calling ``click.get_app_dir(cmd_name)``.\n\n  This defaults to the name of the command as determined by click.\n\n``config_file_name``\n  Default: ``config``\n\n  When ``implicit`` is set to ``True``, this argument provides the name of the\n  configuration file inside the application directory.\n\nIn addition to the arguments above, all arguments for ``click.option()`` and\n``click.File()`` are supported.\n\nSupported file formats\n----------------------\n\nBy default click-config-file supports files formatted according to\n`Configobj's unrepr\nmode \u003chttp://configobj.readthedocs.io/en/latest/configobj.html#unrepr-mode\u003e`_.\n\nYou can add support for additional configuration providers by setting\nthe ``provider`` keyword argument. This argument expects a callable that\nwill take the configuration file path and command name as arguments and\nreturns a dictionary with the provided configuration options.\n\nThe command name is passed in order to allow for a shared configuration\nfile divided by sections for each command.\n\nFor example, this will read the configuration options from a shared JSON\nfile:\n\n.. code-block:: python\n\n    def myprovider(file_path, cmd_name):\n        with open(file_path) as config_data:\n            return json.load(config_data)[cmd_name]\n    \n    @click.command()\n    @click.option('--name', default='World')\n    @click_config_file.configuration_option(provider=myprovider)\n    def hello(name):\n        click.echo('Hello {}!'.format(name))\n\n\nInstallation\n------------\n\n``pip install click-config-file``\n\nWhy?\n----\n\nThere are several existing implementations of config file support for\nClick, however they seem to lack one or more of the following features:\n\n-   Sensible defaults\n-   Proper handling of resolution order\n-   Support for multi value options, multiple options or a combination\n    of both\n\nIn contrast this module may lack some more sophisticated features of the\nother implementations. This is a deliberate choice as this module is\nintended to be a simple option that Just Works with sensible defaults.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphha%2Fclick_config_file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphha%2Fclick_config_file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphha%2Fclick_config_file/lists"}