Skip to content
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

Add [interval [count]] positional arguments #31

Merged
merged 9 commits into from
Feb 1, 2022
Merged

Conversation

Freaky
Copy link
Collaborator

@Freaky Freaky commented Feb 1, 2022

This adds [interval [count]] positional arguments, and changes the default iteration count to 1, bringing it in line with other iostat-alikes.

This involves a somewhat ugly hack with argparse - we add a dummy positional named interval [count] which, thanks to the prior dataset positional, will never be filled. We then extract them from dataset manually after parsing.

This is traditional iostat argument style, so it seems sensible to
support it ourselves.

Also, as is tradition, default to a count of 1, so only the initial
summary is shown.
Add skip_iter and take_iter functions which skip n/yield at most n
elements from an iterator, and replace islice with them.

This makes the diff_loop setup tidier and easier to reason about.
There's no need for this to be a generator - just let it pop off n
iterations and return the original.
Restore interval as a float
This makes calc_name_width simpler, since it's not defining a new method
inline.
Simplify some conditionals to avoid having to worry about None quite so
much, and add a few comments to help explain why we're doing stuff.
Instead of setting dest to a wonky-but-hey-it-works value, suppress it
entirely and override metavar instead.
@Freaky Freaky marked this pull request as ready for review February 1, 2022 17:16
@Freaky Freaky merged commit 8a16368 into main Feb 1, 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.

1 participant