-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: refactored ui package to allow (#882)
- Loading branch information
Showing
7 changed files
with
145 additions
and
86 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
package ui | ||
|
||
import ( | ||
"io" | ||
"os" | ||
) | ||
|
||
// Verbose adds additional info messages e.g. in case of checking errors | ||
var Verbose = false | ||
|
||
var Writer io.Writer = os.Stdout | ||
|
||
// IconMedal emoji | ||
const IconMedal = "🥇" | ||
|
||
// IconError emoji | ||
const IconError = "💔" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// simple ui - TODO use something more sophisticated :) | ||
package ui | ||
|
||
import ( | ||
"io" | ||
"os" | ||
) | ||
|
||
var ui = NewStdoutUI(Verbose) | ||
|
||
func NewUI(verbose bool, writer io.Writer) *UI { | ||
return &UI{ | ||
Verbose: verbose, | ||
Writer: writer, | ||
} | ||
} | ||
|
||
func NewStdoutUI(verbose bool) *UI { | ||
return &UI{ | ||
Verbose: verbose, | ||
Writer: os.Stdout, | ||
} | ||
} | ||
|
||
type UI struct { | ||
Verbose bool | ||
Writer io.Writer | ||
} | ||
|
||
func ExitOnError(item string, errors ...error) { ui.ExitOnError(item, errors...) } | ||
func PrintOnError(item string, errors ...error) { ui.PrintOnError(item, errors...) } | ||
func WarnOnError(item string, errors ...error) { ui.WarnOnError(item, errors...) } | ||
func Logo() { ui.Logo() } | ||
func LogoNoColor() { ui.LogoNoColor() } | ||
func NL() { ui.NL() } | ||
func Success(message string, subMessages ...string) { ui.Success(message, subMessages...) } | ||
func Warn(message string, subMessages ...string) { ui.Warn(message, subMessages...) } | ||
func LogLine(message string) { ui.LogLine(message) } | ||
func Debug(message string, subMessages ...string) { ui.Debug(message, subMessages...) } | ||
func Info(message string, subMessages ...string) { ui.Info(message, subMessages...) } | ||
func Err(err error) { ui.Err(err) } | ||
func Errf(err string, params ...interface{}) { ui.Errf(err, params...) } | ||
func Fail(err error) { ui.Fail(err) } | ||
func Failf(err string, params ...interface{}) { ui.Failf(err, params...) } | ||
func CommandOutput(output []byte, command string, params ...string) { | ||
ui.CommandOutput(output, command, params...) | ||
} | ||
func Medal() { ui.Medal() } | ||
func Completed(message string, subMessages ...string) { ui.Completed(message, subMessages...) } | ||
func GroupCompleted(main string, sub ...string) { ui.GroupCompleted(main, sub...) } | ||
func InfoGrid(table map[string]string) { ui.InfoGrid(table) } | ||
func Vector(table []string) { ui.Vector(table) } | ||
func ShellCommand(title string, commands ...string) { ui.ShellCommand(title, commands...) } | ||
func Table(tableData TableData, writer io.Writer) { ui.Table(tableData, writer) } | ||
func JSONTable(tableData TableData, writer io.Writer) error { return ui.JSONTable(tableData, writer) } | ||
func NewArrayTable(a [][]string) ArrayTable { return ui.NewArrayTable(a) } |