Commit f83793b
Gunter Schmidt
feat: Introducing a new parser for all utils
This is a new fully working parser for the arg options.
The parser is written generically so it can be used in all diffutils tools.
The first implementation is done with sdiff. I already have a version for cmp as well.
I checked and discarded clap as tool, as the requirements are very individual and would require extensive tweaking of the clap functionality.
Features:
- Allows options to be abbreviated, e.g. --wi instead of --width
- Allows input like in GNU utils, e.g. the following are all identical
- diff --ignore-case --minimal --width=50 file_a file_b
- diff --ignore-case --minimal --width 50 file_a file_b
- diff -i -d -w 50 file_a file_b
- diff -id -w50 file_a file_b
- diff -idw50 file_a file_b
- A number parser is available, which parses option arguments
with optional byte units, e.g. =1024 or =1024KiB
- Default handling for --version and --help
- Returns the params or an Error Enum, which makes it library friendly.
- Contains error handling for the typical parsing errors:
-- missing and extra operands
-- invalid, ambiguous or conflicting options
-- missing or not allowed option arguments
- Provides error text functions, e.g. add executable and 'Try --help' to message.1 parent 5660d0e commit f83793b
4 files changed
Lines changed: 914 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | | - | |
| 53 | + | |
52 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
0 commit comments