Skip to content

Feat sdiff inital with parser#193

Open
GunterSchmidt wants to merge 4 commits intouutils:mainfrom
GunterSchmidt:feat--sdiff-inital-with-parser
Open

Feat sdiff inital with parser#193
GunterSchmidt wants to merge 4 commits intouutils:mainfrom
GunterSchmidt:feat--sdiff-inital-with-parser

Conversation

@GunterSchmidt
Copy link
Contributor

Add the sdiff utility in a basic version, see issue #16.

The PR replaces the PRs #159 and #188 as their content is merged in here.

Also a new parser is introduced, as I found too many issues when working with cmp.

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 revised 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.

Gunter Schmidt added 4 commits March 9, 2026 10:59
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant