Commit 7e9e0c3
committed
Print the help when --help or -h is unexpectedly encountered.
Most binaries used on Linux support the '--help' argument, this
is a convention specified by the [GNU project][1], as well as in
the [clig][2].
Currently, adding `--help` after a failing command gives an error,
following by an note at the end on how to get the help. Actually
getting the help usually involves pressing the up arrow, removing the
erroneous `--help` at the end, moving the cursor to after `picotool`
to insert `help` and then succesfully printing out the help.
This commit adds a new error type to the parser to distinguish
between parse errors, and errors that can be identified as an attempt
to obtain the help. This help error is raised only if an unexpected
argument called `--help` is encountered, or an unexpected option `-h`.
In the `main.cpp` this specific error is now caught and handled on
appropriately, still relying on the outer catch problematic parse
errors, like using command names that don't exist.
[1]: https://www.gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html
[2]: https://clig.dev/#help1 parent de8ae5a commit 7e9e0c3
2 files changed
+21
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
1023 | 1027 | | |
1024 | 1028 | | |
1025 | 1029 | | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
1026 | 1037 | | |
1027 | 1038 | | |
1028 | 1039 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1618 | 1618 | | |
1619 | 1619 | | |
1620 | 1620 | | |
1621 | | - | |
1622 | | - | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
1623 | 1631 | | |
1624 | 1632 | | |
1625 | 1633 | | |
| |||
0 commit comments