@@ -25,50 +25,48 @@ import (
2525 "github.com/spf13/cobra"
2626)
2727
28- var (
29- StatsCmd = & cobra.Command {
30- Use : "stats <manifest>" ,
31- Short : "display statistics about the specified manifest" ,
32- Run : func (cmd * cobra.Command , args []string ) {
33- if len (args ) != 1 {
34- log .Fatalln ("please specify a manifest" )
35- }
28+ var StatsCmd = & cobra.Command {
29+ Use : "stats <manifest>" ,
30+ Short : "display statistics about the specified manifest" ,
31+ Run : func (cmd * cobra.Command , args []string ) {
32+ if len (args ) != 1 {
33+ log .Fatalln ("please specify a manifest" )
34+ }
3635
37- bm , err := readManifestFile (args [0 ])
38- if err != nil {
39- log .Fatalf ("error reading manifest: %v" , err )
40- }
36+ bm , err := readManifestFile (args [0 ])
37+ if err != nil {
38+ log .Fatalf ("error reading manifest: %v" , err )
39+ }
4140
42- var stats struct {
43- resources int
44- files int
45- directories int
46- totalSize int64
47- symlinks int
48- }
41+ var stats struct {
42+ resources int
43+ files int
44+ directories int
45+ totalSize int64
46+ symlinks int
47+ }
4948
50- for _ , entry := range bm .Resource {
51- stats .resources ++
52- stats .totalSize += int64 (entry .Size )
49+ for _ , entry := range bm .Resource {
50+ stats .resources ++
51+ stats .totalSize += int64 (entry .Size )
5352
54- mode := os .FileMode (entry .Mode )
55- if mode .IsRegular () {
56- stats .files += len (entry .Path ) // count hardlinks!
57- } else if mode .IsDir () {
58- stats .directories ++
59- } else if mode & os .ModeSymlink != 0 {
60- stats .symlinks ++
61- }
53+ mode := os .FileMode (entry .Mode )
54+ if mode .IsRegular () {
55+ stats .files += len (entry .Path ) // count hardlinks!
56+ } else if mode .IsDir () {
57+ stats .directories ++
58+ } else if mode & os .ModeSymlink != 0 {
59+ stats .symlinks ++
6260 }
61+ }
6362
64- w := newTabwriter (os .Stdout )
65- defer w .Flush ()
63+ w := newTabwriter (os .Stdout )
64+ defer w .Flush ()
6665
67- fmt .Fprintf (w , "resources\t %v\n " , stats .resources )
68- fmt .Fprintf (w , "directories\t %v\n " , stats .directories )
69- fmt .Fprintf (w , "files\t %v\n " , stats .files )
70- fmt .Fprintf (w , "symlinks\t %v\n " , stats .symlinks )
71- fmt .Fprintf (w , "size\t %v\n " , humanize .Bytes (uint64 (stats .totalSize )))
72- },
73- }
74- )
66+ fmt .Fprintf (w , "resources\t %v\n " , stats .resources )
67+ fmt .Fprintf (w , "directories\t %v\n " , stats .directories )
68+ fmt .Fprintf (w , "files\t %v\n " , stats .files )
69+ fmt .Fprintf (w , "symlinks\t %v\n " , stats .symlinks )
70+ fmt .Fprintf (w , "size\t %v\n " , humanize .Bytes (uint64 (stats .totalSize )))
71+ },
72+ }
0 commit comments