Skip to content

Commit f83793b

Browse files
author
Gunter Schmidt
committed
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

File tree

Cargo.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@ harness = false
4646

4747
[features]
4848
# default = ["feat_bench_not_diff"]
49-
# Turn bench for diffutils cmp off
49+
# instead of limiting to KiB, MiB, etc, one can write kib, mib, Mb or whatever case.
50+
feat_allow_case_insensitive_number_units = []
51+
# Disable bench for diffutils cmp
5052
feat_bench_not_cmp = []
51-
# Turn bench for diffutils diff off
53+
# Disable bench for diffutils diff
5254
feat_bench_not_diff = []
55+
# Enables a check on options defined in NOT_YET_IMPLEMENTED.
56+
# If on the parser will return an error message in these cases.
57+
# This is preferable when running the util as unsupported options
58+
# are pointed out to the user, but can make tests fail.
59+
feat_check_not_yet_implemented = []

0 commit comments

Comments
 (0)