Skip to content

Commit

Permalink
docs: add help examples
Browse files Browse the repository at this point in the history
  • Loading branch information
neithere committed Dec 30, 2023
1 parent e4df366 commit e31828b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,17 @@ Save it as `greet.py` and try to run it::
$ ./greet.py
Hello unknown user!

It works! Now try passing arguments. Use ``--help`` if unsure.
It works! Now try passing arguments. Use ``--help`` if unsure::

$ ./greet.py --help

usage: greet.py [-h] [name]

positional arguments:
name 'unknown user'

options:
-h, --help show this help message and exit

Multiple positional arguments; limitations
..........................................
Expand Down Expand Up @@ -97,6 +107,16 @@ In that case it's enough to make the function argument `name` "keyword-only"

We just took the previous function and added ``*,`` before the first argument.

Let's check how the app help now look like::

$ ./greet.py --help

usage: greet.py [-h] [-n NAME]

options:
-h, --help show this help message and exit
-n NAME, --name NAME 'unknown user'

Positional vs options: recap
............................

Expand Down

0 comments on commit e31828b

Please sign in to comment.