-
Notifications
You must be signed in to change notification settings - Fork 622
Add --summarize for ls #3517
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
Add --summarize for ls #3517
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
harshavardhana
requested changes
Dec 7, 2020
Member
|
I think I prefer the following style output With the following changes, AWS CLI output looks clumsy, we can make it look better. git diff
diff --git a/cmd/ls-main.go b/cmd/ls-main.go
index 9686230d..df726b03 100644
--- a/cmd/ls-main.go
+++ b/cmd/ls-main.go
@@ -183,6 +183,7 @@ func mainList(cliCtx *cli.Context) error {
console.SetColor("Dir", color.New(color.FgCyan, color.Bold))
console.SetColor("Size", color.New(color.FgYellow))
console.SetColor("Time", color.New(color.FgGreen))
+ console.SetColor("Summarize", color.New(color.Bold))
// check 'ls' cliCtx arguments.
args, isRecursive, isIncomplete, isSummary, timeRef, withOlderVersions := checkListSyntax(ctx, cliCtx)
diff --git a/cmd/ls.go b/cmd/ls.go
index 7899baa9..f1f99acd 100644
--- a/cmd/ls.go
+++ b/cmd/ls.go
@@ -179,8 +179,9 @@ type summaryMessage struct {
// String colorized string message
func (s summaryMessage) String() string {
- message := console.Colorize("Total Objects", fmt.Sprintf("Total Objects: %d", s.TotalObjects)) + "\n" + console.Colorize("Total Size", fmt.Sprintf("%14s %s", "Total Size:", strings.Join(strings.Fields(humanize.IBytes(uint64(s.TotalSize))), "")))
- return message
+ msg := console.Colorize("Summarize", fmt.Sprintf("\nTotal Size: %s", humanize.IBytes(uint64(s.TotalSize))))
+ msg += "\n" + console.Colorize("Summarize", fmt.Sprintf("Total Objects: %d", s.TotalObjects))
+ return msg
}
// JSON jsonified summary message
@@ -258,11 +259,10 @@ func doList(ctx context.Context, clnt Client, isRecursive, isIncomplete, isSumma
printObjectVersions(clnt.GetURL(), perObjectVersions, withOlderVersions, isSummary)
if isSummary {
- sm := summaryMessage{
+ printMsg(summaryMessage{
TotalObjects: totalObjects,
TotalSize: totalSize,
- }
- printMsg(sm)
+ })
}
return cErrThanks for the PR |
Co-authored-by: Harshavardhana <harsha@minio.io>
harshavardhana
approved these changes
Dec 8, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To achieve the same goal as
aws s3 ls --recursive --summarize --human-readable.