8000 dd: create ConversionMode to simplify conversion, blocking, and unblocking by jfinkels · Pull Request #3293 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dd: create ConversionMode to simplify conversion, blocking, and unblocking #3293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 26, 2022

Conversation

jfinkels
Copy link
Collaborator

This pull request creates a new enum ConversionMode to represent the various conversion, blocking, and unblocking combinations and moves the code for parsing the ConversionMode from the command-line arguments up to the parseargs module. This location makes more sense for it because the conversion mode can be determined entirely from the command-line arguments at the time of parsing just like the other parameters. Using an enum for this purpose also eliminates the amount of code we need later on. For example, we replace an if/else if chain in conv_block_unblock_helper() with a match statement instead.

You may find it easier to review each commit on its own.

Replace a cascading `if/else if` chain in `conv_block_unblock_helper()`
with a match statement on a new enum, `ConversionMode`, that enumerates
the various modes in which `dd` can operate.
Move parsing of the `ConversionMode` outside of
`conv_block_unblock_helper()` and up to the code that calls it.
Move the code for parsing the `ConversionMode` to use up to the
`parseargs` module. This location makes more sense for it because the
conversion mode can be determined entirely from the command-line
arguments at the time of parsing just like the other parameters. Using
an enum for this purpose also eliminates the amount of code we need
later on.
@sylvestre sylvestre force-pushed the dd-conv-block-helper-remove-input branch from 687fb47 to f856bfc Compare March 25, 2022 19:56
Copy link
Member
@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@sylvestre sylvestre merged commit 5fba2a7 into uutils:main Mar 26, 2022
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.

3 participants
0