{"action":"created","issue":{"url":"https://api.github.com/repos/mitsuhiko/click/issues/324","labels_url":"https://api.github.com/repos/mitsuhiko/click/issues/324/labels{/name}","comments_url":"https://api.github.com/repos/mitsuhiko/click/issues/324/comments","events_url":"https://api.github.com/repos/mitsuhiko/click/issues/324/events","html_url":"https://github.com/mitsuhiko/click/issues/324","id":67087988,"number":324,"title":"Document how to make envvar defaults behave like normal defaults","user":{"login":"pfmoore","id":1110419,"avatar_url":"https://avatars.githubusercontent.com/u/1110419?v=3","gravatar_id":"","url":"https://api.github.com/users/pfmoore","html_url":"https://github.com/pfmoore","followers_url":"https://api.github.com/users/pfmoore/followers","following_url":"https://api.github.com/users/pfmoore/following{/other_user}","gists_url":"https://api.github.com/users/pfmoore/gists{/gist_id}","starred_url":"https://api.github.com/users/pfmoore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfmoore/subscriptions","organizations_url":"https://api.github.com/users/pfmoore/orgs","repos_url":"https://api.github.com/users/pfmoore/repos","events_url":"https://api.github.com/users/pfmoore/events{/privacy}","received_events_url":"https://api.github.com/users/pfmoore/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mitsuhiko/click/labels/documentation","name":"documentation","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-08T09:25:47Z","updated_at":"2015-04-08T10:37:47Z","closed_at":null,"body":"When an option is given a default, the prompt for that option changes to say ```Enter <option> [default]:``` and the default is used unless the user overrides it. Defaults from environment variables or from the context ```default_map``` do not behave like this, however, but instead *replace* the prompting behaviour, so they behave more like user input than a default.\r\n\r\nWould it be possible to at least add an option to use environment or ```default_map``` defaults in the prompt, rather than the current behaviour (or is there a way of doing this already which I haven't spotted)?\r\n\r\nHere's an example program:\r\n\r\n```python\r\nimport os\r\nfrom configparser import ConfigParser\r\nimport click\r\nimport click.utils\r\n\r\n@click.command()\r\n@click.option('--foo', default='Hello', envvar=\"FOO\", prompt=\"Enter foo\")\r\ndef cli(foo):\r\n    print(\"Foo is\", foo)\r\n\r\nif __name__ == '__main__':\r\n    appini = os.path.join(click.utils.get_app_dir('Clicker'), 'clicker.ini')\r\n    dflt = {}\r\n    if os.path.exists(appini):\r\n        cp = ConfigParser()\r\n        cp.read(appini)\r\n        if cp.has_section('defaults'):\r\n            dflt = cp['defaults']\r\n\r\n    cli(default_map=dflt)\r\n```\r\n\r\nThe intent here is that if the user says ```clicker --foo XXX``` no prompt is issued, but otherwise the user is prompted, with the default coming from the environment, or the application ini file, or the hard-coded \"Hello\" (in that order of preference)."},"comment":{"url":"https://api.github.com/repos/mitsuhiko/click/issues/comments/90875718","html_url":"https://github.com/mitsuhiko/click/issues/324#issuecomment-90875718","issue_url":"https://api.github.com/repos/mitsuhiko/click/issues/324","id":90875718,"user":{"login":"pfmoore","id":1110419,"avatar_url":"https://avatars.githubusercontent.com/u/1110419?v=3","gravatar_id":"","url":"https://api.github.com/users/pfmoore","html_url":"https://github.com/pfmoore","followers_url":"https://api.github.com/users/pfmoore/followers","following_url":"https://api.github.com/users/pfmoore/following{/other_user}","gists_url":"https://api.github.com/users/pfmoore/gists{/gist_id}","starred_url":"https://api.github.com/users/pfmoore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfmoore/subscriptions","organizations_url":"https://api.github.com/users/pfmoore/orgs","repos_url":"https://api.github.com/users/pfmoore/repos","events_url":"https://api.github.com/users/pfmoore/events{/privacy}","received_events_url":"https://api.github.com/users/pfmoore/received_events","type":"User","site_admin":false},"created_at":"2015-04-08T10:37:47Z","updated_at":"2015-04-08T10:37:47Z","body":"I've submitted a PR for a change to the docs, in #325"}}