Skip to content

Commit

Permalink
Add ascii flag for ASCII-only table display
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Apr 8, 2022
1 parent 90dd1c4 commit 7807e17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/spf13/cobra"
)

var asciiPrint bool

// rootCmd represents the base command when called without any subcommands.
var rootCmd = &cobra.Command{
Use: "iSMC",
Expand All @@ -40,3 +42,8 @@ func Execute() {
os.Exit(1)
}
}

func init() {
rootCmd.PersistentFlags().BoolVarP(&asciiPrint, "ascii", "a", false,
"use only ASCII characters when displaying table")
}
4 changes: 3 additions & 1 deletion cmd/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var sensorOutputHeader = table.Row{"Description", "Key", "Value", "Type"} // row

func setupTable(t table.Writer) {
t.SetOutputMirror(os.Stdout)
t.SetStyle(table.StyleColoredBright)
if !asciiPrint {
t.SetStyle(table.StyleColoredBright)
}
t.AppendHeader(sensorOutputHeader)
}

0 comments on commit 7807e17

Please sign in to comment.