|
4 | 4 | "encoding/json" |
5 | 5 | "fmt" |
6 | 6 | "gocldf/cldf" |
| 7 | + "gocldf/internal/pathutil" |
7 | 8 | "io" |
| 9 | + "path/filepath" |
8 | 10 | "text/tabwriter" |
9 | 11 |
|
10 | 12 | "github.com/spf13/cobra" |
@@ -34,15 +36,42 @@ func stats(out io.Writer, mdPath string, withMetadata bool) error { |
34 | 36 | } |
35 | 37 | w := tabwriter.NewWriter(out, 0, 0, 1, ' ', tabwriter.Debug) |
36 | 38 | // noinspection GoUnhandledErrorResultInspection |
37 | | - fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", "Filename", "Component", "Rows", "FKs") |
| 39 | + fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", "Filename", "Component", "Rows", "Size") |
38 | 40 | // noinspection GoUnhandledErrorResultInspection |
39 | | - fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", "--------", "---------", "----", "---") |
| 41 | + fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", "--------", "---------", "--------", "----------") |
40 | 42 | for _, table := range ds.Tables { |
| 43 | + path, err := ds.TablePath(table) |
| 44 | + if err != nil { |
| 45 | + return err |
| 46 | + } |
| 47 | + size, err := pathutil.GetFormattedSize(path) |
| 48 | + if err != nil { |
| 49 | + return err |
| 50 | + } |
41 | 51 | cname := "" |
42 | 52 | if table.Comp != "" { |
43 | 53 | cname = table.CanonicalName |
44 | 54 | } |
45 | | - fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", table.Url, cname, len(table.Data), len(table.ForeignKeys)) |
| 55 | + fmt.Fprintf( |
| 56 | + w, |
| 57 | + "%v\t%v\t%v\t%v\n", |
| 58 | + filepath.Base(path), |
| 59 | + cname, |
| 60 | + fmt.Sprintf("%8s", fmt.Sprintf("%v", len(table.Data))), |
| 61 | + fmt.Sprintf("%10s", size)) |
| 62 | + } |
| 63 | + if ds.Sources != nil { |
| 64 | + size, err := pathutil.GetFormattedSize(ds.Sources.Path) |
| 65 | + if err != nil { |
| 66 | + return err |
| 67 | + } |
| 68 | + fmt.Fprintf( |
| 69 | + w, |
| 70 | + "%v\t%v\t%v\t%v\n", |
| 71 | + filepath.Base(ds.Sources.Path), |
| 72 | + "SourceTable", |
| 73 | + fmt.Sprintf("%8s", fmt.Sprintf("%v", len(ds.Sources.Items))), |
| 74 | + fmt.Sprintf("%10s", size)) |
46 | 75 | } |
47 | 76 | // noinspection GoUnhandledErrorResultInspection |
48 | 77 | w.Flush() |
|
0 commit comments