feat: use my own color pkg to wrap fatih/color (#3)

* feat: use my own color pkg to wrap fatih color

* build: run go mod tidy

Co-authored-by: Tran Hau <ngtranhau@gmail.com>
main
sudo pacman -Syu 2021-04-14 11:32:47 +07:00 committed by GitHub
parent 73ac768289
commit ef390ca1a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 16 deletions

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.16
require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/fatih/color v1.10.0
github.com/haunt98/color v0.1.0
github.com/haunt98/copy-go v0.4.0
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/urfave/cli/v2 v2.3.0

2
go.sum
View File

@ -4,6 +4,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/haunt98/color v0.1.0 h1:qfP5oNI3aoUC8T+bH/JNVAg79ljyhTGpgfqSKWhkiQQ=
github.com/haunt98/color v0.1.0/go.mod h1:V4BPVUSuiOItuVZHRHUTkpxO7OYQiP0DSgIWMpC/2qs=
github.com/haunt98/copy-go v0.4.0 h1:ts47dExLyIWWrnLQmVc475Af3/LO111zeB58waSe02A=
github.com/haunt98/copy-go v0.4.0/go.mod h1:cK1mRlW7QXPHhe5YI1VtL/U4OjUbRLAtZnO/oucrwRI=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=

23
main.go
View File

@ -5,7 +5,7 @@ import (
"os"
"runtime"
"github.com/fatih/color"
"github.com/haunt98/color"
"github.com/urfave/cli/v2"
)
@ -19,22 +19,16 @@ const (
currentDir = "."
)
var (
fmtErr = color.New(color.FgRed)
headerErr = fmt.Sprintf("[%s error]: ", appName)
// denyOSes contains OS which is not supported
// go tool dist list
denyOSes = map[string]struct{}{
"windows": struct{}{},
}
)
// denyOSes contains OS which is not supported
// go tool dist list
var denyOSes = map[string]struct{}{
"windows": struct{}{},
}
func main() {
// Prevent running at runtime
if _, ok := denyOSes[runtime.GOOS]; ok {
fmtErr.Print(headerErr)
fmt.Printf("OS %s is not supported right now\n", runtime.GOOS)
color.PrintAppError(appName, fmt.Sprintf("OS %s is not supported right now", runtime.GOOS))
return
}
@ -67,8 +61,7 @@ func main() {
}
if err := app.Run(os.Args); err != nil {
fmtErr.Print(headerErr)
fmt.Printf("%s\n", err.Error())
color.PrintAppError(appName, err.Error())
}
}