Skip to content

Commit 0b5c6b7

Browse files
authored
Add Best practices section (#3127)
2 parents 7b4e59c + 930b45d commit 0b5c6b7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

docs/design-opinions.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# CLI Design Opinions
2+
3+
```{currentmodule} click
4+
```
5+
A penny for your thoughts...
6+
7+
```{contents}
8+
:depth: 1
9+
:local: true
10+
```
11+
12+
## Options over arguments
13+
{ref}`Positional arguments <arguments>` should be used sparingly, and if used should be required:
14+
- The more positional arguments there are, the more confusing the CLI invocation becomes to read. (This is true of Python too.)
15+
- Making some arguments optional, or arbitrary length, can make it harder to reason about. The parser handles this consistently by filling left to right, with an error if there is a non-optional unfilled after that. But that's not obvious to a user just looking at a command line.
16+
- A command should be doing one thing, and the arguments should be related directly to that.
17+
- A group, where the argument is the sub-command name.
18+
- A command acts on some files.
19+
- A command looks at a source and acts on a destination.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Conceptual Guides
8686
.. toctree::
8787
:maxdepth: 1
8888

89+
design-opinions
8990
why
9091
click-concepts
9192

0 commit comments

Comments
 (0)