Commit Graph
9 Commits
Author SHA1 Message Date
Nate Cook f674173291 Don't let .allUnrecognized consume built-in flags (#550)
Arguments declared with the `.allUnrecognized` parsing strategy
currently capture built-in flags, which isn't intended. This
fixes that issue by looking for built-in flags in the captured
portion of the input before decoding.

Fixes rdar://104990388
2023-02-08 21:02:46 -08:00
David Peterson 587d26a2aa Fixes incorrect value copying when ParseArguments has the same field name+type as the ParseCommand (Issue #322) (#495)
* Contains fixes and test cases for #322
2022-09-22 09:43:48 -05:00
Mike WermuthandMike bafa74a9e4 Fix invalid state error when decoding an unparsed optional value (#290)
Fixes “Internal error. Invalid state while parsing command-line arguments.” that is encountered when an unparsed value is optional.

Root causes:
- `ParsedArgumentsContainer.decodeNil` returns false for optional values because it only does a `!contains(key)` check. This should instead return nil if the value of the element is nil.
- The decoder did not know about unparsed input origins that and would result in unexpected behavior when decoding nil default values.
- The `value` of `Mirror.Child` is defined as `Any` but this is confusing because the value could be `Optional<Any>` which is not equal to `nil` even when the `Optional` case is `.none`.

Co-authored-by: Mike <mike.wermuth@icloud.com>
2021-04-15 01:07:24 -05:00
Nate Cook db24cb1275 Improve parsing performance (#234)
* Convert some linear operations to constant time

* Temporary test command for performance testing

* Improve SplitArguments docs

* Re-enable split arguments unit test

* Restore repeat example
2020-09-01 09:31:42 -05:00
John Mueller f07d2fb107 Enable default for option and argument arrays (#186)
* Enable default for option and argument arrays

* Moved array reset to ParsedValues
2020-06-22 13:53:31 -05:00
Nate Cook 1fa25574f8 Show option-based errors before unexpected positional errors (#187)
This pushes any errors indicated by unexpected arguments after parsing
out to the same late position. We were previously stopping immediately
when the command is a leaf node; that isn't necessary and created an
awkward second error path.
2020-06-15 14:32:36 -05:00
Šimon Javora 4d2be90027 Remove code the compiler can generate on its own. Removed public annotations nested inside internal types. (#22) 2020-03-02 11:25:07 -06:00
Wildchild9 6f58e68a6a Fixed Various Grammar & Spelling Mistakes (#17)
* Corrected grammatical and spelling errors in files in Documentation.

* Correct various spelling, grammar, and formatting mistakes in code documentation.
2020-03-02 10:54:10 -06:00
Nate Cook f6ac7b8118 Initial import of ArgumentParser 2020-02-27 15:45:22 -06:00