Compare commits
No commits in common. "ba7c3ac52dd0f740c31dbacb688724463ec4d79b" and "ed2d941259430a8a0fc3802899f51efe1952cf7e" have entirely different histories.
ba7c3ac52d
...
ed2d941259
2 changed files with 5 additions and 26 deletions
|
@ -23,6 +23,7 @@ var (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := run(); err != nil {
|
if err := run(); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "ERROR: %v.\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,18 +181,13 @@ func run() error {
|
||||||
|
|
||||||
exe, ok := executorMap[command]
|
exe, ok := executorMap[command]
|
||||||
if !ok {
|
if !ok {
|
||||||
err := executor.UnknownCommandError{Command: command}
|
|
||||||
|
|
||||||
printer.PrintFailure(err.Error() + ".")
|
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
|
|
||||||
return err
|
return executor.UnknownCommandError{Command: command}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := executor.Execute(exe, args); err != nil {
|
if err := executor.Execute(exe, args); err != nil {
|
||||||
printer.PrintFailure("(" + command + ") " + err.Error() + ".")
|
return fmt.Errorf("(%s) %w", command, err)
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -12,10 +12,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
minTerminalWidth = 40
|
|
||||||
)
|
|
||||||
|
|
||||||
type theme struct {
|
type theme struct {
|
||||||
reset string
|
reset string
|
||||||
boldblue string
|
boldblue string
|
||||||
|
@ -23,8 +19,6 @@ type theme struct {
|
||||||
green string
|
green string
|
||||||
boldgreen string
|
boldgreen string
|
||||||
grey string
|
grey string
|
||||||
red string
|
|
||||||
boldred string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Printer struct {
|
type Printer struct {
|
||||||
|
@ -53,12 +47,6 @@ func NewPrinter(
|
||||||
green: "\033[32m",
|
green: "\033[32m",
|
||||||
boldgreen: "\033[32;1m",
|
boldgreen: "\033[32;1m",
|
||||||
grey: "\033[90m",
|
grey: "\033[90m",
|
||||||
red: "\033[31m",
|
|
||||||
boldred: "\033[31;1m",
|
|
||||||
}
|
|
||||||
|
|
||||||
if maxTerminalWidth < minTerminalWidth {
|
|
||||||
maxTerminalWidth = minTerminalWidth
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Printer{
|
return &Printer{
|
||||||
|
@ -77,7 +65,7 @@ func NewPrinter(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) PrintSuccess(text string) {
|
func (p Printer) PrintSuccess(text string) {
|
||||||
success := p.theme.boldgreen + p.successSymbol + p.theme.reset
|
success := p.theme.green + p.successSymbol + p.theme.reset
|
||||||
if p.noColor {
|
if p.noColor {
|
||||||
success = p.successSymbol
|
success = p.successSymbol
|
||||||
}
|
}
|
||||||
|
@ -86,12 +74,7 @@ func (p Printer) PrintSuccess(text string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) PrintFailure(text string) {
|
func (p Printer) PrintFailure(text string) {
|
||||||
failure := p.theme.boldred + p.failureSymbol + p.theme.reset
|
printToStderr(p.failureSymbol + " " + text)
|
||||||
if p.noColor {
|
|
||||||
failure = p.failureSymbol
|
|
||||||
}
|
|
||||||
|
|
||||||
printToStderr(failure + " " + text + "\n")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) PrintInfo(text string) {
|
func (p Printer) PrintInfo(text string) {
|
||||||
|
|
Loading…
Reference in a new issue