Skip to content
Myr

Merge pull request #1855 from guifelix/patch-1

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Update why.rst

authored by David Lord · committed by GitHub · parents 56e79c9, 94d3710 · Browse files · 1 file+12 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−12 removed

  • other:+12 added−12 removed

1 file+12 added−12 removed

modified:docs/why.rst+12 added-12 removed
5 unmodified lines
67This question is easy to answer: because there is not a single command8line utility for Python out there which ticks the following boxes:910* is lazily composable without restrictions11* supports implementation of Unix/POSIX command line conventions12* supports loading values from environment variables out of the box13* support for prompting of custom values14* is fully nestable and composable15* supports file handling out of the box16* comes with useful common helpers (getting terminal dimensions,10* Is lazily composable without restrictions.11* Supports implementation of Unix/POSIX command line conventions.12* Supports loading values from environment variables out of the box.13* Support for prompting of custom values.14* Is fully nestable and composable.15* Supports file handling out of the box.16* Comes with useful common helpers (getting terminal dimensions,17 ANSI colors, fetching direct keyboard input, screen clearing,18 finding config paths, launching apps and editors, etc.)18 finding config paths, launching apps and editors, etc.).1920There are many alternatives to Click; the obvious ones are ``optparse``21and ``argparse`` from the standard library. Have a look to see if something22else resonates with you.
22 unmodified lines
45-----------------4647Click is internally based on ``optparse`` instead of ``argparse``. This48is an implementation detail that a user does not have to be concerned49with. Click is not based on argparse because it has some behaviors that49with. Click is not based on ``argparse`` because it has some behaviors that50make handling arbitrary command line interfaces hard:5152* argparse has built-in behavior to guess if something is an52* ``argparse`` has built-in behavior to guess if something is an53 argument or an option. This becomes a problem when dealing with54 incomplete command lines; the behaviour becomes unpredictable55 without full knowledge of a command line. This goes against Click's56 ambitions of dispatching to subparsers.57* argparse does not support disabling interspersed arguments. Without57* ``argparse`` does not support disabling interspersed arguments. Without58 this feature, it's not possible to safely implement Click's nested59 parsing.6061Why not Docopt etc.?
71 unmodified lines
133Why No Auto Correction?134-----------------------135136The question came up why Click does not auto correct parameters given that137even optparse and argparse support automatic expansion of long arguments.137even optparse and ``argparse`` support automatic expansion of long arguments.138The reason for this is that it's a liability for backwards compatibility.139If people start relying on automatically modified parameters and someone140adds a new parameter in the future, the script might stop working. These141kinds of problems are hard to find, so Click does not attempt to be magical
5 unmodified lines