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

Merged
merged 2 commits into from
May 15, 2017

Conversation

kevina
Copy link
Contributor

@kevina kevina commented May 11, 2017

Closes #3836.

@kevina
Copy link
Contributor Author

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?

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
@kevina kevina force-pushed the kevina/repo-stat-storagemax branch from 5abc198 to 0f46a34 Compare May 11, 2017 03:41
@hsanjuan
Copy link
Contributor

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

Also, code looks good to me.

@whyrusleeping
Copy link
Member

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

@kevina
Copy link
Contributor Author

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
Copy link
Member

Sounds good to me!

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
Copy link
Member

@whyrusleeping whyrusleeping left a comment

Choose a reason for hiding this comment

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

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
@whyrusleeping whyrusleeping deleted the kevina/repo-stat-storagemax branch May 15, 2017 19:27
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