Skip to content

Conversation

BenWiederhake
Copy link
Contributor

This PR demonstrates how the weird --text/--binary/--tag/--untagged logic in cksum can be done in 12 very easy lines:

    Arg::Binary => self.binary = Tristate::True,
    Arg::Text => self.binary = Tristate::False,
    Arg::Tag => {
        self.binary = Tristate::Unset;
        self.tag = Tristate::True;
    }
    Arg::Untagged => {
        if self.tag == Tristate::True {
            self.binary = Tristate::Unset;
        }
        self.tag = Tristate::False;
    }

Reverse-engineering this was a bit of a trouble: uutils/coreutils#6364

In particular, note how much easier the above piece of logic is to read than having to reconstruct it from clap: uutils/coreutils@d4b9bc0

This is an advertisement for uutils-args as a replacement of clap :)

@BenWiederhake
Copy link
Contributor Author

Changes since last push:

  • cargo fmt (whoops)

The clippy failure is fixed by #118.

@tertsdiepraam tertsdiepraam merged commit 9ef4080 into uutils:main May 6, 2024
@tertsdiepraam
Copy link
Member

Yes! This is where uutils-args shines 😄 Let's publish this crate next week so we can start using it.

@BenWiederhake BenWiederhake deleted the dev-cksum branch May 6, 2024 14:26
@BenWiederhake
Copy link
Contributor Author

Please also consider #113, since it is necessary for some utils :)

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.

2 participants