Skip to content

Commit

Permalink
release: v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
owlinux1000 committed Oct 1, 2023
1 parent bcac69f commit 2afdd0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ var rootCmd = &cobra.Command{
}

withColorized, _ := cmd.Flags().GetBool("no-color")
withSize, _ := cmd.Flags().GetBool("filesize")
option := internal.PrintOption{
WithColorized: !withColorized,
WithSize: withSize,
}
gcsTree, err := internal.NewGCSTree(ctx, client, bucket, &option)
if err != nil {
Expand All @@ -60,4 +62,5 @@ func Execute() {
func init() {
rootCmd.Flags().BoolP("version", "v", false, "show the gcstree version")
rootCmd.Flags().BoolP("no-color", "n", false, "disable colorized outputs")
rootCmd.Flags().BoolP("filesize", "f", false, "show the file size")
}
2 changes: 1 addition & 1 deletion internal/gcstree.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"google.golang.org/api/iterator"
)

const GCSTREE_VERSION = "0.0.5"
const GCSTREE_VERSION = "1.0.0"

type GCSTree struct {
bucket string
Expand Down
9 changes: 8 additions & 1 deletion internal/tree.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package internal

import (
"fmt"
"path/filepath"
"strings"

Expand All @@ -22,8 +23,14 @@ func tree(bucket string, objList []*storage.ObjectAttrs, option *PrintOption) (s
if s == "" {
continue
}
originalFilename := s
if option.WithSize {
if s == file {
s = fmt.Sprintf("[%4s] %s", formatBytes(obj.Size), s)
}
}
if option.WithColorized {
if s != file {
if originalFilename != file {
s = color.BlueString("%s", s)
}
}
Expand Down

0 comments on commit 2afdd0f

Please sign in to comment.