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 MaxStorage field to output of "repo stat". #3915

Merged
merged 2 commits into from May 15, 2017

Conversation

Projects
None yet
3 participants
@kevina
Contributor

kevina commented May 11, 2017

Closes #3836.

@kevina

This comment has been minimized.

Contributor

kevina commented May 11, 2017

Note, with the current way formatting is done the output comes out as:

$ ipfs repo stat --human
NumObjects       1586
RepoSize (MiB)   67
StorageMax (MiB)         9536
RepoPath         /tmp/gocode2-ipfs
Version          fs-repo@5

Due to this code:

			buf := new(bytes.Buffer)
			fmt.Fprintf(buf, "NumObjects \t %d\n", stat.NumObjects)
			sizeInMiB := stat.RepoSize / (1024 * 1024)
			if human && sizeInMiB > 0 {
				fmt.Fprintf(buf, "RepoSize (MiB) \t %d\n", sizeInMiB)
			} else {
				fmt.Fprintf(buf, "RepoSize \t %d\n", stat.RepoSize)
			}
			maxSizeInMiB := stat.StorageMax / (1024 * 1024)
			if human && maxSizeInMiB > 0 {
				fmt.Fprintf(buf, "StorageMax (MiB) \t %d\n", maxSizeInMiB)
			} else {
				fmt.Fprintf(buf, "StorageMax \t %d\n", stat.StorageMax)
			}
			fmt.Fprintf(buf, "RepoPath \t %s\n", stat.RepoPath)
			fmt.Fprintf(buf, "Version \t %s\n", stat.Version)

should we perhaps not use tab in the output? Although removing the tab will make the output more difficult to parse. My vote would be to use:

NumObjects:       1586
RepoSize (MiB):   67
StorageMax (MiB): 9536
RepoPath:         /tmp/gocode2-ipfs
Version:          fs-repo@5

With a colon after the field names. But maybe that is for another P.R.

@whyrusleeping thoughts?

Add MaxStorage field to output of "repo stat".
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
@hsanjuan

This comment has been minimized.

Contributor

hsanjuan commented May 12, 2017

I prefer nicely formatted outputs. Parsing should be done on json output anyway...

Also, code looks good to me.

@whyrusleeping

This comment has been minimized.

Member

whyrusleeping commented May 12, 2017

@kevina you could use a tabwriter (from the stdlib) That is fine with me

@kevina

This comment has been minimized.

Contributor

kevina commented May 12, 2017

@whyrusleeping okay I will do that, and also add a colon after the fields names as that makes reading it easier. Sound good?

@whyrusleeping

This comment has been minimized.

Member

whyrusleeping commented May 12, 2017

Sounds good to me!

Use tabwritter for better formatted output.
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
@whyrusleeping

LGTM

@whyrusleeping whyrusleeping added this to the Ipfs 0.4.10 milestone May 12, 2017

@whyrusleeping whyrusleeping merged commit 219b41b into master May 15, 2017

5 of 8 checks passed

continuous-integration/travis-ci/push The Travis CI build could not complete due to an error
Details
codecov/patch 57.89% of diff hit (target 62.6%)
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
ci/circleci Your tests passed on CircleCI!
Details
codeclimate no new or fixed issues
Details
codecov/project 62.79% (+0.19%) compared to a6e96e6
Details
commit-message-check/gitcop All commit messages are valid
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details

@whyrusleeping whyrusleeping deleted the kevina/repo-stat-storagemax branch May 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment