Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.

Comments

Implement and exhaustively test cksum's weird implicit flags in 12 lines#122

Merged
tertsdiepraam merged 1 commit intouutils:mainfrom
BenWiederhake:dev-cksum
May 6, 2024
Merged

Implement and exhaustively test cksum's weird implicit flags in 12 lines#122
tertsdiepraam merged 1 commit intouutils:mainfrom
BenWiederhake:dev-cksum

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
Collaborator

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants