diff --git a/lib/datamodel/cmd/list.go b/lib/datamodel/cmd/list.go index 041bf738..fb25d25a 100644 --- a/lib/datamodel/cmd/list.go +++ b/lib/datamodel/cmd/list.go @@ -9,10 +9,11 @@ import ( "github.com/hofstadter-io/hof/cmd/hof/flags" "github.com/hofstadter-io/hof/lib/datamodel" "github.com/hofstadter-io/hof/lib/runtime" + "github.com/hofstadter-io/hof/lib/yagu" ) func list(R *runtime.Runtime, dflags flags.DatamodelPflagpole) error { - return printAsTable( + return yagu.PrintAsTable( []string{"Name", "Type", "Version", "Status", "ID"}, func(table *tablewriter.Table) ([][]string, error) { var rows = make([][]string, 0, len(R.Datamodels)) diff --git a/lib/datamodel/cmd/table.go b/lib/datamodel/cmd/table.go deleted file mode 100644 index e4bf29f3..00000000 --- a/lib/datamodel/cmd/table.go +++ /dev/null @@ -1,42 +0,0 @@ -package cmd - -import ( - "os" - - "github.com/olekukonko/tablewriter" -) - -func defaultTableFormat(table *tablewriter.Table) { - table.SetAutoWrapText(false) - table.SetAutoFormatHeaders(true) - table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) - table.SetAlignment(tablewriter.ALIGN_LEFT) - table.SetCenterSeparator("") - table.SetColumnSeparator("") - table.SetRowSeparator("") - table.SetHeaderLine(false) - table.SetBorder(false) - table.SetTablePadding(" ") - table.SetNoWhiteSpace(true) -} - -type dataPrinter func(table *tablewriter.Table) ([][]string, error) - -func printAsTable(headers []string, printer dataPrinter) error { - table := tablewriter.NewWriter(os.Stdout) - table.SetHeader(headers) - - defaultTableFormat(table) - - rows, err := printer(table) - if err != nil { - return err - } - - table.AppendBulk(rows) - - // render - table.Render() - - return nil -} diff --git a/lib/datamodel/cmd/utils.go b/lib/datamodel/cmd/utils.go index 9bcb3dac..bf77f8dd 100644 --- a/lib/datamodel/cmd/utils.go +++ b/lib/datamodel/cmd/utils.go @@ -14,6 +14,4 @@ func findMaxLabelLen(R *runtime.Runtime, dflags flags.DatamodelPflagpole) int { } } return max -} - - +} \ No newline at end of file diff --git a/lib/gen/cmd/list.go b/lib/gen/cmd/list.go index 8c7a7315..b8f1ee55 100644 --- a/lib/gen/cmd/list.go +++ b/lib/gen/cmd/list.go @@ -39,20 +39,4 @@ func List(args []string, rflags flags.RootPflagpole, gflags flags.GenFlagpole) e return rows, nil }, ) - - // // TODO... - // // 1. use table printer - // // 2. move this command up, large blocks of this ought - // gens := make([]string, 0, len(R.Generators)) - // for _, G := range R.Generators { - // gens = append(gens, G.Hof.Metadata.Name) - // } - // if len(gens) == 0 { - // return fmt.Errorf("no generators found") - // } - // fmt.Printf("Available Generators\n ") - // fmt.Println(strings.Join(gens, "\n ")) - - // // print gens - // return nil }