Skip to content

Commit

Permalink
restructuring display functions to a separate package
Browse files Browse the repository at this point in the history
  • Loading branch information
lemoncrust committed Jul 27, 2022
1 parent ef6adb7 commit 01ce33a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions cmd/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package cmd
import (
"fmt"

"github.com/open-traffic-generator/otgen/display"
"github.com/spf13/cobra"
)

Expand All @@ -45,12 +46,12 @@ For more information, go to https://github.com/open-traffic-generator/otgen
Run: func(cmd *cobra.Command, args []string) {
switch displayType {
case TYPE_CHARTS:
err := chartsFn(cmd, args)
err := display.ChartsFn(cmd, args)
if err != nil {
log.Fatal(err)
}
case TYPE_TABLE:
err := tableFn(cmd, args)
err := display.TableFn(cmd, args)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/charts.go → display/charts.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package display

import (
"context"
Expand Down Expand Up @@ -121,7 +121,7 @@ func (cp *ChartProcessor) Layout(data []DataPoint) error {
return cp.cnt.Update("root", co...)
}

func chartsFn(cmd *cobra.Command, args []string) error {
func ChartsFn(cmd *cobra.Command, args []string) error {
t, err := tcell.New()
if err != nil {
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/table.go → display/table.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package display

import (
"fmt"
Expand Down Expand Up @@ -71,7 +71,7 @@ func (tp *TableProcessor) Format() string {
return tableString.String()
}

func tableFn(cmd *cobra.Command, args []string) error {
func TableFn(cmd *cobra.Command, args []string) error {
tp := &TableProcessor{
headers: []string{},
data: map[string]map[string]string{},
Expand Down
4 changes: 3 additions & 1 deletion cmd/utils.go → display/utils.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package cmd
package display

import (
"bufio"
"encoding/json"
"os"
"sync"

log "github.com/sirupsen/logrus"
)

// TODO: would be nice to make it configurable or automatically determined
Expand Down

0 comments on commit 01ce33a

Please sign in to comment.