This was breaking UsageOnMissing() when combined with validation of
positional arguments, in that it was allowing positional arguments to be
omitted. It also broke UsageOnMissing() somehow so that it did not work.
Refactors usageOnMissing option to not run parent commands after
printing usage when a child node is missing.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Adds an UsageOnMissing option which configures Kong to omit errors and
display usage when a command is invalid due to a missing argument. This
can be useful if a user wishes for the top-level command to print usage
when no args are supplied, or if they would prefer child commands which
have their own subcommands to print usage specific to that command.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Factor out some repetition from `parseTag()` into a `GetSep()` method so
as to simplify `parseTag()` and formalise the semantics of a separator.
The existing behaviour in corner/error cases has been preserved, but an
appropriate error is returned (currently ignored) so a future breaking
change could be made to handle these conditions.
Tests have not been added as the test files are in a separate package to
the unit under test, making direct `Tag` construction difficult. Testing
through the exported APIs is already performed in the
`FormatPlaceHolder()` tests.
Use the specified separators for a flag in the placeholders printed in
the help message for slices and maps. Do not print the separator and
ellipsis if the separator is disabled (`"none"`).
Previously the default separator was printed with an ellipsis, ignoring
the `sep` and `mapsep` tags.
Add tests for `Flag.FormatPlaceHolder()`.
According to the README.md, a value of `"none"` for the `sep` tag (for
slices) and `mapsep` (for maps) is meant to disable the separator that
would allow multiple entries to be added from a single argument.
However, using `"none"` just set the separator to the rune `'n'`.
Fix the parsing of the tag, and also update `SplitEscaped` to not split
with a separator of `-1`.
Add a new test for the new cases.
Commit c77deac080 in PR #83 added `h` as
the short flag for help, but the help tests were not updated. Update the
tests with the `-h` in the help output.
This is useful for situations where the initialisation of some object
should be deferred, eg. when there are distinct "setup" and "use" phases
to a tools lifecycle.