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 --bytes/-b flag to display byte counts instead of human-readable values #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nadesai
Copy link

@nadesai nadesai commented Sep 12, 2018

This PR addresses #6, though very inelegantly.

  • Creates a new flag --bytes that displays byte values instead of human-readable values for all output. (I put Google Translate-based guesses in for French and German translations, as I don't speak those languages.)
  • Modifies the (unused) display_item function to work with any reference to T implementing Display; also adds a display_bytes flag. Updates all code locations where file or directory sizes are printed so that this function is used. (This introduces a check that size != FileSize::new(0) in all print statements, which does not match prior behavior e.g. at https://github.com/vmchale/tin-summer/pull/12/files#diff-9801ad6b6d07be3a4b68f9fd9e3b9832R273 or at https://github.com/vmchale/tin-summer/pull/12/files#diff-5899cfb17ab780a6ee6255135e9f06feR680. This would be easy to rectify if there is a concern.)
  • Modifies the read_all, read_all_fast, display_tree fns, and the Walk struct, to add parameters or fields capturing whether or not data should be displayed as bytes.
  • Modifies relevant invocations of all these functions to take the correct parameter for displaying the bytes value.

Some things still need to be addressed:

  • No tests exist to validate behavior with -b.
  • Length of byte value strings varies wildly, so during printing with byte values, not all file names or directory names start at the same column.

Please let me know what I can change in this PR to make it usable - this is my first time attempting to contribute to this project.

@nadesai nadesai changed the title Add -bytes/-b flag to display byte counts instead of human-readable values Add --bytes/-b flag to display byte counts instead of human-readable values Sep 16, 2018
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