wer
This commit is contained in:
parent
13cd379d1a
commit
59666d0dd6
42
ceph/ceph.go
42
ceph/ceph.go
|
|
@ -23,21 +23,21 @@ func makeMonQuery(cephConn *cephConnection, query map[string]string) []byte {
|
|||
return monRawAnswer
|
||||
}
|
||||
|
||||
func getPoolSize(cephConn *cephConnection, params string) Poolinfo {
|
||||
monRawAnswer := makeMonQuery(cephConn, map[string]string{"prefix": "osd pool get", "pool": params,
|
||||
"format": "json", "var": "size"})
|
||||
monAnswer := Poolinfo{}
|
||||
if err := json.Unmarshal([]byte(monRawAnswer), &monAnswer); err != nil {
|
||||
log.Fatalf("Can't parse monitor answer. Error: %v", err)
|
||||
}
|
||||
return monAnswer
|
||||
func getCommands(cephConn *cephConnection) []byte {
|
||||
monRawAnswer := makeMonQuery(cephConn, map[string]string{"prefix": "get_command_descriptions"})
|
||||
return monRawAnswer
|
||||
|
||||
}
|
||||
|
||||
func CloseConn(cephConn *cephConnection) {
|
||||
fmt.Println("Closing connection to cluster")
|
||||
cephConn.conn.Shutdown()
|
||||
}
|
||||
func main() {
|
||||
var connect cephConnection
|
||||
var err error
|
||||
var poolInfo Poolinfo
|
||||
// var poolInfo Poolinfo
|
||||
var monAnswer interface{}
|
||||
|
||||
fmt.Println("Creating connection object")
|
||||
connect.conn,err = rados.NewConn()
|
||||
|
|
@ -46,17 +46,23 @@ func main() {
|
|||
}
|
||||
connect.conn.ReadConfigFile("/etc/ceph/ceph.conf")
|
||||
connect.conn.Connect()
|
||||
defer connect.conn.Shutdown()
|
||||
defer CloseConn(&connect)
|
||||
|
||||
poolInfo = getPoolSize(&connect,"test")
|
||||
fmt.Println(poolInfo)
|
||||
// monAnswer = getCommands(&connect)
|
||||
|
||||
// poolnames,err := connect.conn.ListPools()
|
||||
// if err != nil {
|
||||
// log.Fatal("Cannot list pools")
|
||||
// }
|
||||
err = json.Unmarshal(getCommands(&connect), &monAnswer)
|
||||
if err != nil {
|
||||
log.Fatalln("Cannot unmarshal")
|
||||
}
|
||||
|
||||
prettyForm, err := json.MarshalIndent(monAnswer,""," ")
|
||||
if err != nil {
|
||||
log.Fatalln("Second unmarshallin not successful")
|
||||
}
|
||||
|
||||
fmt.Println(string(prettyForm))
|
||||
// hum,_ := json.MarshalIndent(monAnswer, "", " ")
|
||||
// fmt.Println(monAnswer)
|
||||
|
||||
// for i,j := range poolnames {
|
||||
// fmt.Printf("%d %s\n",i,j)
|
||||
}
|
||||
|
||||
|
|
|
|||
10
menu/go.mod
Normal file
10
menu/go.mod
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
module main.go
|
||||
|
||||
go 1.24.6
|
||||
|
||||
require (
|
||||
github.com/daviddengcn/go-colortext v1.0.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
gopkg.in/dixonwille/wlog.v2 v2.0.0 // indirect
|
||||
)
|
||||
14
menu/go.sum
Normal file
14
menu/go.sum
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX8ATG8oKsE=
|
||||
github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c=
|
||||
github.com/dixonwille/wmenu v4.0.2+incompatible h1:lxrPJsx9LpdUFD5T+dOfl6gPKLbBmiAtEdACLT1I2/w=
|
||||
github.com/dixonwille/wmenu v4.0.2+incompatible/go.mod h1:DnajdZEKFQksxBctWekpWaQXQrDUHRBco6b8MyZnR1s=
|
||||
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho=
|
||||
github.com/golangplus/bytes v1.0.0/go.mod h1:AdRaCFwmc/00ZzELMWb01soso6W1R/++O1XL80yAn+A=
|
||||
github.com/golangplus/fmt v1.0.0/go.mod h1:zpM0OfbMCjPtd2qkTD/jX2MgiFCqklhSUFyDW44gVQE=
|
||||
github.com/golangplus/testing v1.0.0/go.mod h1:ZDreixUV3YzhoVraIDyOzHrr76p6NUh6k/pPg/Q3gYA=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/dixonwille/wlog.v2 v2.0.0 h1:TbGWtD8ahWVSihKKr+z2Dw7Cv/7IrfN6dwrcrre17pU=
|
||||
gopkg.in/dixonwille/wlog.v2 v2.0.0/go.mod h1:JYQHRnhGPLno/iATOiGkEXoRanJXqdz9Qo6/QwfARUc=
|
||||
12
menu/main.go
Normal file
12
menu/main.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package menu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
|
||||
|
||||
func main() {
|
||||
menu := wmen
|
||||
}
|
||||
1
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/list
vendored
Normal file
1
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/list
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
v1.0.0
|
||||
1
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.info
vendored
Normal file
1
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.info
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"Version":"v1.0.0","Time":"2020-03-29T21:11:09Z"}
|
||||
0
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.lock
vendored
Normal file
0
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.lock
vendored
Normal file
8
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.mod
vendored
Normal file
8
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.mod
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
module github.com/daviddengcn/go-colortext
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/golangplus/bytes v1.0.0 // indirect
|
||||
github.com/golangplus/testing v1.0.0
|
||||
)
|
||||
BIN
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.zip
vendored
Normal file
BIN
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.zip
vendored
Normal file
Binary file not shown.
1
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.ziphash
vendored
Normal file
1
pkg/mod/cache/download/github.com/daviddengcn/go-colortext/@v/v1.0.0.ziphash
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX8ATG8oKsE=
|
||||
2
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/list
vendored
Normal file
2
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/list
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
v1.0.6
|
||||
v4.0.2+incompatible
|
||||
1
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v1.0.6.mod
vendored
Normal file
1
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v1.0.6.mod
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
module github.com/dixonwille/wmenu
|
||||
1
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.info
vendored
Normal file
1
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.info
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"Version":"v4.0.2+incompatible","Time":"2018-01-05T18:19:49Z"}
|
||||
0
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.lock
vendored
Normal file
0
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.lock
vendored
Normal file
1
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.mod
vendored
Normal file
1
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.mod
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
module github.com/dixonwille/wmenu
|
||||
BIN
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.zip
vendored
Normal file
BIN
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.zip
vendored
Normal file
Binary file not shown.
1
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.ziphash
vendored
Normal file
1
pkg/mod/cache/download/github.com/dixonwille/wmenu/@v/v4.0.2+incompatible.ziphash
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
h1:lxrPJsx9LpdUFD5T+dOfl6gPKLbBmiAtEdACLT1I2/w=
|
||||
2
pkg/mod/cache/download/github.com/golangplus/bytes/@v/list
vendored
Normal file
2
pkg/mod/cache/download/github.com/golangplus/bytes/@v/list
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
v0.0.0-20160111154220-45c989fe5450
|
||||
v1.0.0
|
||||
1
pkg/mod/cache/download/github.com/golangplus/bytes/@v/v0.0.0-20160111154220-45c989fe5450.mod
vendored
Normal file
1
pkg/mod/cache/download/github.com/golangplus/bytes/@v/v0.0.0-20160111154220-45c989fe5450.mod
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
module github.com/golangplus/bytes
|
||||
5
pkg/mod/cache/download/github.com/golangplus/bytes/@v/v1.0.0.mod
vendored
Normal file
5
pkg/mod/cache/download/github.com/golangplus/bytes/@v/v1.0.0.mod
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
module github.com/golangplus/bytes
|
||||
|
||||
go 1.14
|
||||
|
||||
require github.com/golangplus/testing v1.0.0
|
||||
1
pkg/mod/cache/download/github.com/golangplus/fmt/@v/list
vendored
Normal file
1
pkg/mod/cache/download/github.com/golangplus/fmt/@v/list
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
v1.0.0
|
||||
3
pkg/mod/cache/download/github.com/golangplus/fmt/@v/v1.0.0.mod
vendored
Normal file
3
pkg/mod/cache/download/github.com/golangplus/fmt/@v/v1.0.0.mod
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module github.com/golangplus/fmt
|
||||
|
||||
go 1.14
|
||||
1
pkg/mod/cache/download/github.com/golangplus/testing/@v/list
vendored
Normal file
1
pkg/mod/cache/download/github.com/golangplus/testing/@v/list
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
v1.0.0
|
||||
8
pkg/mod/cache/download/github.com/golangplus/testing/@v/v1.0.0.mod
vendored
Normal file
8
pkg/mod/cache/download/github.com/golangplus/testing/@v/v1.0.0.mod
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
module github.com/golangplus/testing
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450
|
||||
github.com/golangplus/fmt v1.0.0
|
||||
)
|
||||
1
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/list
vendored
Normal file
1
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/list
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
v0.0.20
|
||||
1
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.info
vendored
Normal file
1
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.info
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"Version":"v0.0.20","Time":"2023-10-17T07:28:21Z","Origin":{"VCS":"git","URL":"https://github.com/mattn/go-isatty","Hash":"a7c02353c47bc4ec6b30dc9628154ae4fe760c11","Ref":"refs/tags/v0.0.20"}}
|
||||
0
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.lock
vendored
Normal file
0
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.lock
vendored
Normal file
5
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.mod
vendored
Normal file
5
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.mod
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
module github.com/mattn/go-isatty
|
||||
|
||||
go 1.15
|
||||
|
||||
require golang.org/x/sys v0.6.0
|
||||
BIN
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.zip
vendored
Normal file
BIN
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.zip
vendored
Normal file
Binary file not shown.
1
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.ziphash
vendored
Normal file
1
pkg/mod/cache/download/github.com/mattn/go-isatty/@v/v0.0.20.ziphash
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
2
pkg/mod/cache/download/golang.org/x/sys/@v/list
vendored
Normal file
2
pkg/mod/cache/download/golang.org/x/sys/@v/list
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
v0.6.0
|
||||
v0.35.0
|
||||
1
pkg/mod/cache/download/golang.org/x/sys/@v/v0.35.0.info
vendored
Normal file
1
pkg/mod/cache/download/golang.org/x/sys/@v/v0.35.0.info
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"Version":"v0.35.0","Time":"2025-08-06T21:03:43Z","Origin":{"VCS":"git","URL":"https://go.googlesource.com/sys","Hash":"5b936e1f126baa13682eff91c2e4d5d9e3a0b71d","Ref":"refs/tags/v0.35.0"}}
|
||||
3
pkg/mod/cache/download/golang.org/x/sys/@v/v0.35.0.mod
vendored
Normal file
3
pkg/mod/cache/download/golang.org/x/sys/@v/v0.35.0.mod
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module golang.org/x/sys
|
||||
|
||||
go 1.23.0
|
||||
0
pkg/mod/cache/download/golang.org/x/sys/@v/v0.6.0.lock
vendored
Normal file
0
pkg/mod/cache/download/golang.org/x/sys/@v/v0.6.0.lock
vendored
Normal file
3
pkg/mod/cache/download/golang.org/x/sys/@v/v0.6.0.mod
vendored
Normal file
3
pkg/mod/cache/download/golang.org/x/sys/@v/v0.6.0.mod
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module golang.org/x/sys
|
||||
|
||||
go 1.17
|
||||
BIN
pkg/mod/cache/download/golang.org/x/sys/@v/v0.6.0.zip
vendored
Normal file
BIN
pkg/mod/cache/download/golang.org/x/sys/@v/v0.6.0.zip
vendored
Normal file
Binary file not shown.
1
pkg/mod/cache/download/golang.org/x/sys/@v/v0.6.0.ziphash
vendored
Normal file
1
pkg/mod/cache/download/golang.org/x/sys/@v/v0.6.0.ziphash
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
1
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/list
vendored
Normal file
1
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/list
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
v2.0.0
|
||||
1
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.info
vendored
Normal file
1
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.info
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"Version":"v2.0.0","Time":"2017-02-22T03:43:20Z"}
|
||||
0
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.lock
vendored
Normal file
0
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.lock
vendored
Normal file
1
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.mod
vendored
Normal file
1
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.mod
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
module gopkg.in/dixonwille/wlog.v2
|
||||
BIN
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.zip
vendored
Normal file
BIN
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.zip
vendored
Normal file
Binary file not shown.
1
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.ziphash
vendored
Normal file
1
pkg/mod/cache/download/gopkg.in/dixonwille/wlog.v2/@v/v2.0.0.ziphash
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
h1:TbGWtD8ahWVSihKKr+z2Dw7Cv/7IrfN6dwrcrre17pU=
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
1005358
|
||||
github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX8ATG8oKsE=
|
||||
github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c=
|
||||
|
||||
go.sum database tree
|
||||
43191231
|
||||
qHm0EQ3KgyaK0OqkvYk3oQYgEdXK/VSsNYlbZRCb3Pw=
|
||||
|
||||
— sum.golang.org Az3grtfyLGjokX0/tVEfOzpGVUN+QbORZDiM3OQLiEhL2tPBek1hNZ5pL2xWN480RcOycWNpRJ6Y2VZGFE7rW9sv/Qs=
|
||||
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/dixonwille/wmenu@v1.0.6
vendored
Normal file
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/dixonwille/wmenu@v1.0.6
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
200592
|
||||
github.com/dixonwille/wmenu v1.0.6 h1:LGglnOOozO+lLyh38JcUAYEMal4n7qU4mfUmkB5Tewo=
|
||||
github.com/dixonwille/wmenu v1.0.6/go.mod h1:DnajdZEKFQksxBctWekpWaQXQrDUHRBco6b8MyZnR1s=
|
||||
|
||||
go.sum database tree
|
||||
43191517
|
||||
7EyyR27fHHZvBXkJPRXdQwdS4rdhTkZYoT5hKpGlnnc=
|
||||
|
||||
— sum.golang.org Az3grtQelJ8vIsOksGofUjCjg30znYS84OnPtg45zIGkgsYtRvVvixn/AMUG1ZJbvI/au4bh0r9HnjvoptRWwOWr9Q8=
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
166897
|
||||
github.com/dixonwille/wmenu v4.0.2+incompatible h1:lxrPJsx9LpdUFD5T+dOfl6gPKLbBmiAtEdACLT1I2/w=
|
||||
github.com/dixonwille/wmenu v4.0.2+incompatible/go.mod h1:DnajdZEKFQksxBctWekpWaQXQrDUHRBco6b8MyZnR1s=
|
||||
|
||||
go.sum database tree
|
||||
43191376
|
||||
DIOQQw4mW9S2sQW62NxA334oBLi5bVg6Nj117r5CumM=
|
||||
|
||||
— sum.golang.org Az3grm/s8odMDAP2t4Kt0zSlfanJpM/KZl4AIHNW7gKuFvkJtyMyuvnYD556OUPLChd1N/oPhBgfUpczsHCXHDgTigI=
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
1688
|
||||
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 h1:7xqw01UYS+KCI25bMrPxwNYkSns2Db1ziQPpVq99FpE=
|
||||
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho=
|
||||
|
||||
go.sum database tree
|
||||
43191621
|
||||
CPpOpnVoazY4kNwzZTjKVhSXeOozossXQNa2UaER874=
|
||||
|
||||
— sum.golang.org Az3grs07kGysb2oy7poMGiocHtxStJiWkIY5aXWTE/8z587hOHyTt7/2zEwxImAeHn6zBMh7pk4WYTlw2h0A3GS/PA4=
|
||||
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/golangplus/bytes@v1.0.0
vendored
Normal file
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/golangplus/bytes@v1.0.0
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
1005311
|
||||
github.com/golangplus/bytes v1.0.0 h1:YQKBijBVMsBxIiXT4IEhlKR2zHohjEqPole4umyDX+c=
|
||||
github.com/golangplus/bytes v1.0.0/go.mod h1:AdRaCFwmc/00ZzELMWb01soso6W1R/++O1XL80yAn+A=
|
||||
|
||||
go.sum database tree
|
||||
43191434
|
||||
uUgGgJJ11/evLXIVRDwX7BtLpBGIWimWLbbQ9Q68BDk=
|
||||
|
||||
— sum.golang.org Az3grjxycAWElvF12OWPfckTbbldhvtCrWLR2kvTEYuM+1NByk0Ljje8r7BXdaxTmC5gosnwsAqlIWaAD0upft68mwg=
|
||||
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/golangplus/fmt@v1.0.0
vendored
Normal file
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/golangplus/fmt@v1.0.0
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
1005266
|
||||
github.com/golangplus/fmt v1.0.0 h1:FnUKtw86lXIPfBMc3FimNF3+ABcV+aH5F17OOitTN+E=
|
||||
github.com/golangplus/fmt v1.0.0/go.mod h1:zpM0OfbMCjPtd2qkTD/jX2MgiFCqklhSUFyDW44gVQE=
|
||||
|
||||
go.sum database tree
|
||||
43191559
|
||||
edMTV+ivJ5B37CQXVJCLAAjeMST4od34ze2/+pBcoVo=
|
||||
|
||||
— sum.golang.org Az3gru0G0VTkySWK+XC96DWVPPkh3rc+0hFRm3pXrv8oUaVqcv9NrDkfxGyxQPYeLYCccAhsQ8sq4uzk5fc1YK+E4g0=
|
||||
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/golangplus/testing@v1.0.0
vendored
Normal file
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/golangplus/testing@v1.0.0
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
1005305
|
||||
github.com/golangplus/testing v1.0.0 h1:+ZeeiKZENNOMkTTELoSySazi+XaEhVO0mb+eanrSEUQ=
|
||||
github.com/golangplus/testing v1.0.0/go.mod h1:ZDreixUV3YzhoVraIDyOzHrr76p6NUh6k/pPg/Q3gYA=
|
||||
|
||||
go.sum database tree
|
||||
43191533
|
||||
maZW25aF1f5oVvbLBzQe0YSd+DCY1S1KxqIf7RdEO3c=
|
||||
|
||||
— sum.golang.org Az3grsaj+H35f61nbG8uSkJKc/SP53ijXTRhpNfFl8pZpm5F3q1XHgm6fLHEEBfdnAsdXbdRJ336ezAQuvKae+pYMgA=
|
||||
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/mattn/go-isatty@v0.0.20
vendored
Normal file
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/mattn/go-isatty@v0.0.20
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
20103885
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
|
||||
go.sum database tree
|
||||
43190277
|
||||
3sXu5/jRWbnpx0n8SDcDfFJz4DEw13hovHu+DNv47bo=
|
||||
|
||||
— sum.golang.org Az3grrx6yeO58h59oW1E7xQm+Fovz9EiK94MrFF3TkHviAe6RxYSm36W5fRLvXFgjuDPtFMkRROmualxlJpdxS4E9QI=
|
||||
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/golang.org/x/sys@v0.35.0
vendored
Normal file
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/golang.org/x/sys@v0.35.0
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
41721156
|
||||
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
|
||||
go.sum database tree
|
||||
43188730
|
||||
J2dNtgSfeQdU383Ai26yrXFKwdgxrnH2RL54WrtVYes=
|
||||
|
||||
— sum.golang.org Az3grr7Cs/piAs7SsfsJwBOk3neQJID0R85JZulrLK7ZhMlUfib7p1XECPtvCe8G84QYqbSHaZ/8V6sMW2FccU966QI=
|
||||
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/golang.org/x/sys@v0.6.0
vendored
Normal file
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/golang.org/x/sys@v0.6.0
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
16177722
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
||||
go.sum database tree
|
||||
43189576
|
||||
bKD0/PXJfMy7gcRUqBwYlQeA7Z1dKAXz832FirMsEaQ=
|
||||
|
||||
— sum.golang.org Az3grvfUZuwRiHMSJf+TUZHhcCWe0sGshW5QRBx5ZMZC+4yX9BzrS4ADJHHJxM2LwKYETPsF3CxXRmkipno1vIsrQw4=
|
||||
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/gopkg.in/dixonwille/wlog.v2@v2.0.0
vendored
Normal file
9
pkg/mod/cache/download/sumdb/sum.golang.org/lookup/gopkg.in/dixonwille/wlog.v2@v2.0.0
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
166898
|
||||
gopkg.in/dixonwille/wlog.v2 v2.0.0 h1:TbGWtD8ahWVSihKKr+z2Dw7Cv/7IrfN6dwrcrre17pU=
|
||||
gopkg.in/dixonwille/wlog.v2 v2.0.0/go.mod h1:JYQHRnhGPLno/iATOiGkEXoRanJXqdz9Qo6/QwfARUc=
|
||||
|
||||
go.sum database tree
|
||||
43191692
|
||||
qWxr/VHR84emiDefVcES1LiNYT1rge7571whsp167Bs=
|
||||
|
||||
— sum.golang.org Az3grgO12q3fua7W82xGucR3qBMahgw66LQXZJCESkk+zk7OXVESW3LIqjVMTKqA9jLEBm7DlBUpAU61MnGbrTUp7wg=
|
||||
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/006
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/006
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/651
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/651
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/783
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/783
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x003/926
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x003/926
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x003/927
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x003/927
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x063/194
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x063/194
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x078/530
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x078/530
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x162/973
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x162/973
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/705
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/705
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/709
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/709
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/712
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/712
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/715
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/715
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/716
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/716
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/716.p/221
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/716.p/221
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/717.p/140
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x168/717.p/140
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/000
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/000
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/002
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/002
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/003
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/003
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/015
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/015
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/246
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/246
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/306
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/306
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/636
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/636
vendored
Normal file
Binary file not shown.
5
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/659.p/12
vendored
Normal file
5
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/659.p/12
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Éþ¼„˜–”;_Txl%šëŽÍHÐsR¨wj
|
||||
^³’ù¢ŸÎ7§ªä0˜Õ·] <20>O²<4F>1á³ÁÉYÍù
|
||||
…l¨†»Ölœ~Ù8×0Ðnœ&âiáåçÈbIaïÐbÇ[yÖ½V=¼KÞ kà Ë(]Ñé½®\‚`Éè"!tÆ"'<1B>ºõÑ~¾APˆ©?Û]J>= ™îíª¡èŒ±ò•+¥ùË·ÏgJ1«%û3¢TŸZ7&ñ4‘W™~–ðg£÷‘¬y‚-<2D>*?¦ˆpc4®ÐçÌ “ìie"Ñ f¼ËÞÒ¡{!5Ÿ·"«¡Ï-=m0žFJ) dª¾5°â·
oÛ<6F>¶\ÆÄ}PÓj$Ãȃ<Â1œ¨s[2 øà"ÌBÆ^ÂÑPf
<0A>&´|Tï±³§ l*tŒŽ'a§SA™C=Æ1‡üM +þrXßéyºZÅ1<C385>•™<¹íV<
|
||||
¸¶®BP”½t»)µ
|
||||
}©`A¶2
|
||||
5
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/659.p/13
vendored
Normal file
5
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/659.p/13
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Éþ¼„˜–”;_Txl%šëŽÍHÐsR¨wj
|
||||
^³’ù¢ŸÎ7§ªä0˜Õ·] <20>O²<4F>1á³ÁÉYÍù
|
||||
…l¨†»Ölœ~Ù8×0Ðnœ&âiáåçÈbIaïÐbÇ[yÖ½V=¼KÞ kà Ë(]Ñé½®\‚`Éè"!tÆ"'<1B>ºõÑ~¾APˆ©?Û]J>= ™îíª¡èŒ±ò•+¥ùË·ÏgJ1«%û3¢TŸZ7&ñ4‘W™~–ðg£÷‘¬y‚-<2D>*?¦ˆpc4®ÐçÌ “ìie"Ñ f¼ËÞÒ¡{!5Ÿ·"«¡Ï-=m0žFJ) dª¾5°â·
oÛ<6F>¶\ÆÄ}PÓj$Ãȃ<Â1œ¨s[2 øà"ÌBÆ^ÂÑPf
<0A>&´|Tï±³§ l*tŒŽ'a§SA™C=Æ1‡üM +þrXßéyºZÅ1<C385>•™<¹íV<
|
||||
¸¶®BP”½t»)µ
|
||||
}©`A¶2c’ŠÕ¿Ô'ë¹$\xÎæ¦5ô•£í3%üe -ì‹…
|
||||
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/2/000
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/2/000
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/2/001
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/2/001
vendored
Normal file
Binary file not shown.
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/2/002.p/147
vendored
Normal file
BIN
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/2/002.p/147
vendored
Normal file
Binary file not shown.
3
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/3/000.p/2
vendored
Normal file
3
pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/3/000.p/2
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
o
|
||||
”@m°%q±£T`…ow!^ñ¾Z—{§<>Ë<EFBFBD>éÐvÍ빜5Ñ1 "sJ®YFØñ Ç
|
||||
iÂéè¶9Z•Æ9Æ
|
||||
22
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/.gitignore
vendored
Normal file
22
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
54
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/LICENSE
Normal file
54
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/LICENSE
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
BSD License
|
||||
===========
|
||||
|
||||
Copyright (c) 2016, David Deng
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of go-colortext nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
MIT License
|
||||
===========
|
||||
|
||||
Copyright (c) 2016 David Deng
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
21
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/README.md
Normal file
21
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/README.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
go-colortext package [](http://go-search.org/view?id=github.com%2Fdaviddengcn%2Fgo-colortext)
|
||||
====================
|
||||
|
||||
This is a package to change the color of the text and background in the console, working both under Windows and other systems.
|
||||
|
||||
Under Windows, the console APIs are used. Otherwise, ANSI texts are output.
|
||||
|
||||
Docs: http://godoc.org/github.com/daviddengcn/go-colortext ([packages that import ct](http://go-search.org/view?id=github.com%2fdaviddengcn%2fgo-colortext))
|
||||
|
||||
Usage:
|
||||
```go
|
||||
ct.Foreground(Green, false)
|
||||
fmt.Println("Green text starts here...")
|
||||
ct.ChangeColor(Red, true, White, false)
|
||||
fmt.Println(...)
|
||||
ct.ResetColor()
|
||||
```
|
||||
|
||||
LICENSE
|
||||
=======
|
||||
BSD/MIT license
|
||||
53
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/ct.go
Normal file
53
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/ct.go
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
ct package provides functions to change the color of console text.
|
||||
|
||||
Under windows platform, the Console API is used. Under other systems, ANSI text mode is used.
|
||||
*/
|
||||
package ct
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Color is the type of color to be set.
|
||||
type Color int
|
||||
|
||||
const (
|
||||
// No change of color
|
||||
None = Color(iota)
|
||||
Black
|
||||
Red
|
||||
Green
|
||||
Yellow
|
||||
Blue
|
||||
Magenta
|
||||
Cyan
|
||||
White
|
||||
)
|
||||
|
||||
// Writer is the io.Writer where ANSI escape codes will be written to
|
||||
var Writer io.Writer = os.Stdout
|
||||
|
||||
// ResetColor resets the foreground and background to original colors
|
||||
func ResetColor() {
|
||||
resetColor()
|
||||
}
|
||||
|
||||
// ChangeColor sets the foreground and background colors. If the value of the color is None,
|
||||
// the corresponding color keeps unchanged.
|
||||
// If fgBright or bgBright is set true, corresponding color use bright color. bgBright may be
|
||||
// ignored in some OS environment.
|
||||
func ChangeColor(fg Color, fgBright bool, bg Color, bgBright bool) {
|
||||
changeColor(fg, fgBright, bg, bgBright)
|
||||
}
|
||||
|
||||
// Foreground changes the foreground color.
|
||||
func Foreground(cl Color, bright bool) {
|
||||
ChangeColor(cl, bright, None, false)
|
||||
}
|
||||
|
||||
// Background changes the background color.
|
||||
func Background(cl Color, bright bool) {
|
||||
ChangeColor(None, false, cl, bright)
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// +build !windows
|
||||
|
||||
package ct
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func isDumbTerm() bool {
|
||||
return os.Getenv("TERM") == "dumb"
|
||||
}
|
||||
|
||||
func resetColor() {
|
||||
if isDumbTerm() {
|
||||
return
|
||||
}
|
||||
fmt.Fprint(Writer, "\x1b[0m")
|
||||
}
|
||||
|
||||
func ansiText(fg Color, fgBright bool, bg Color, bgBright bool) string {
|
||||
if fg == None && bg == None {
|
||||
return ""
|
||||
}
|
||||
s := []byte("\x1b[0")
|
||||
if fg != None {
|
||||
s = strconv.AppendUint(append(s, ";"...), 30+(uint64)(fg-Black), 10)
|
||||
if fgBright {
|
||||
s = append(s, ";1"...)
|
||||
}
|
||||
}
|
||||
if bg != None {
|
||||
s = strconv.AppendUint(append(s, ";"...), 40+(uint64)(bg-Black), 10)
|
||||
if bgBright {
|
||||
s = append(s, ";1"...)
|
||||
}
|
||||
}
|
||||
s = append(s, "m"...)
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func changeColor(fg Color, fgBright bool, bg Color, bgBright bool) {
|
||||
if isDumbTerm() {
|
||||
return
|
||||
}
|
||||
if fg == None && bg == None {
|
||||
return
|
||||
}
|
||||
fmt.Fprint(Writer, ansiText(fg, fgBright, bg, bgBright))
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// +build !windows
|
||||
|
||||
package ct
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/golangplus/testing/assert"
|
||||
)
|
||||
|
||||
func TestAnsiText(t *testing.T) {
|
||||
assert.Equal(t, "ansiText", ansiText(None, false, None, false), "")
|
||||
assert.Equal(t, "ansiText", ansiText(Red, false, None, false), "\x1b[0;31m")
|
||||
assert.Equal(t, "ansiText", ansiText(Red, true, None, false), "\x1b[0;31;1m")
|
||||
assert.Equal(t, "ansiText", ansiText(None, false, Green, false), "\x1b[0;42m")
|
||||
assert.Equal(t, "ansiText", ansiText(Red, false, Green, false), "\x1b[0;31;42m")
|
||||
assert.Equal(t, "ansiText", ansiText(Red, true, Green, false), "\x1b[0;31;1;42m")
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package ct
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestChangeColor(t *testing.T) {
|
||||
defer ResetColor()
|
||||
fmt.Println("Normal text...")
|
||||
text := "This is an demo of using ChangeColor to output colorful texts"
|
||||
i := 1
|
||||
for _, c := range text {
|
||||
ChangeColor(Color(i/2%8)+Black, i%2 == 1, Color((i+2)/2%8)+Black, false)
|
||||
fmt.Print(string(c))
|
||||
i++
|
||||
}
|
||||
fmt.Println()
|
||||
ChangeColor(Red, true, White, false)
|
||||
fmt.Println("Before reset.")
|
||||
ChangeColor(Red, false, White, true)
|
||||
fmt.Println("Before reset.")
|
||||
ResetColor()
|
||||
fmt.Println("After reset.")
|
||||
fmt.Println("After reset.")
|
||||
}
|
||||
|
||||
func TestForeground(t *testing.T) {
|
||||
ResetColor()
|
||||
defer ResetColor()
|
||||
|
||||
fmt.Println("Please check the words under the following text shows with the corresponding front color:")
|
||||
|
||||
colorToText := [...]string{
|
||||
Black: "black",
|
||||
Red: "red",
|
||||
Green: "green",
|
||||
Yellow: "yellow",
|
||||
Blue: "blue",
|
||||
Magenta: "magenta",
|
||||
Cyan: "cyan",
|
||||
White: "white",
|
||||
}
|
||||
for i, txt := range colorToText {
|
||||
cl := Color(i)
|
||||
if cl != None {
|
||||
Foreground(cl, false)
|
||||
fmt.Print(txt, ",")
|
||||
Foreground(cl, true)
|
||||
fmt.Print(txt, ",")
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func TestBackground(t *testing.T) {
|
||||
ResetColor()
|
||||
defer ResetColor()
|
||||
|
||||
fmt.Println("Please check the words under the following text shows with the corresponding background color:")
|
||||
|
||||
colorToText := [...]string{
|
||||
Black: "black",
|
||||
Red: "red",
|
||||
Green: "green",
|
||||
Yellow: "yellow",
|
||||
Blue: "blue",
|
||||
Magenta: "magenta",
|
||||
Cyan: "cyan",
|
||||
White: "white",
|
||||
}
|
||||
for i, txt := range colorToText {
|
||||
cl := Color(i)
|
||||
if cl != None {
|
||||
Background(cl, false)
|
||||
fmt.Print(txt, ",")
|
||||
Background(cl, true)
|
||||
fmt.Print(txt, ",")
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
133
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/ct_win.go
Normal file
133
pkg/mod/github.com/daviddengcn/go-colortext@v1.0.0/ct_win.go
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
// +build windows
|
||||
|
||||
package ct
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var fg_colors = []uint16{
|
||||
0,
|
||||
0,
|
||||
foreground_red,
|
||||
foreground_green,
|
||||
foreground_red | foreground_green,
|
||||
foreground_blue,
|
||||
foreground_red | foreground_blue,
|
||||
foreground_green | foreground_blue,
|
||||
foreground_red | foreground_green | foreground_blue}
|
||||
|
||||
var bg_colors = []uint16{
|
||||
0,
|
||||
0,
|
||||
background_red,
|
||||
background_green,
|
||||
background_red | background_green,
|
||||
background_blue,
|
||||
background_red | background_blue,
|
||||
background_green | background_blue,
|
||||
background_red | background_green | background_blue}
|
||||
|
||||
const (
|
||||
foreground_blue = uint16(0x0001)
|
||||
foreground_green = uint16(0x0002)
|
||||
foreground_red = uint16(0x0004)
|
||||
foreground_intensity = uint16(0x0008)
|
||||
background_blue = uint16(0x0010)
|
||||
background_green = uint16(0x0020)
|
||||
background_red = uint16(0x0040)
|
||||
background_intensity = uint16(0x0080)
|
||||
|
||||
foreground_mask = foreground_blue | foreground_green | foreground_red | foreground_intensity
|
||||
background_mask = background_blue | background_green | background_red | background_intensity
|
||||
)
|
||||
|
||||
var (
|
||||
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
|
||||
procGetStdHandle = kernel32.NewProc("GetStdHandle")
|
||||
procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
|
||||
procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
|
||||
|
||||
hStdout uintptr
|
||||
initScreenInfo *console_screen_buffer_info
|
||||
)
|
||||
|
||||
func setConsoleTextAttribute(hConsoleOutput uintptr, wAttributes uint16) bool {
|
||||
ret, _, _ := procSetConsoleTextAttribute.Call(
|
||||
hConsoleOutput,
|
||||
uintptr(wAttributes))
|
||||
return ret != 0
|
||||
}
|
||||
|
||||
type coord struct {
|
||||
X, Y int16
|
||||
}
|
||||
|
||||
type small_rect struct {
|
||||
Left, Top, Right, Bottom int16
|
||||
}
|
||||
|
||||
type console_screen_buffer_info struct {
|
||||
DwSize coord
|
||||
DwCursorPosition coord
|
||||
WAttributes uint16
|
||||
SrWindow small_rect
|
||||
DwMaximumWindowSize coord
|
||||
}
|
||||
|
||||
func getConsoleScreenBufferInfo(hConsoleOutput uintptr) *console_screen_buffer_info {
|
||||
var csbi console_screen_buffer_info
|
||||
if ret, _, _ := procGetConsoleScreenBufferInfo.Call(hConsoleOutput, uintptr(unsafe.Pointer(&csbi))); ret == 0 {
|
||||
return nil
|
||||
}
|
||||
return &csbi
|
||||
}
|
||||
|
||||
const (
|
||||
std_output_handle = uint32(-11 & 0xFFFFFFFF)
|
||||
)
|
||||
|
||||
func init() {
|
||||
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||
|
||||
procGetStdHandle = kernel32.NewProc("GetStdHandle")
|
||||
|
||||
hStdout, _, _ = procGetStdHandle.Call(uintptr(std_output_handle))
|
||||
|
||||
initScreenInfo = getConsoleScreenBufferInfo(hStdout)
|
||||
|
||||
syscall.LoadDLL("")
|
||||
}
|
||||
|
||||
func resetColor() {
|
||||
if initScreenInfo == nil { // No console info - Ex: stdout redirection
|
||||
return
|
||||
}
|
||||
setConsoleTextAttribute(hStdout, initScreenInfo.WAttributes)
|
||||
}
|
||||
|
||||
func changeColor(fg Color, fgBright bool, bg Color, bgBright bool) {
|
||||
attr := uint16(0)
|
||||
if fg == None || bg == None {
|
||||
cbufinfo := getConsoleScreenBufferInfo(hStdout)
|
||||
if cbufinfo == nil { // No console info - Ex: stdout redirection
|
||||
return
|
||||
}
|
||||
attr = cbufinfo.WAttributes
|
||||
}
|
||||
if fg != None {
|
||||
attr = attr & ^foreground_mask | fg_colors[fg]
|
||||
if fgBright {
|
||||
attr |= foreground_intensity
|
||||
}
|
||||
}
|
||||
if bg != None {
|
||||
attr = attr & ^background_mask | bg_colors[bg]
|
||||
if bgBright {
|
||||
attr |= background_intensity
|
||||
}
|
||||
}
|
||||
setConsoleTextAttribute(hStdout, attr)
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// Package ctfmt is a handful wrapping of go-colortext (ct) package and fmt package.
|
||||
package ctfmt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/daviddengcn/go-colortext"
|
||||
)
|
||||
|
||||
// Print calls fmt.Print with foreground color set.
|
||||
func Print(cl ct.Color, bright bool, a ...interface{}) (n int, err error) {
|
||||
ct.Foreground(cl, bright)
|
||||
defer ct.ResetColor()
|
||||
|
||||
return fmt.Print(a...)
|
||||
}
|
||||
|
||||
// Println calls fmt.Println with foreground color set.
|
||||
func Println(cl ct.Color, bright bool, a ...interface{}) (n int, err error) {
|
||||
ct.Foreground(cl, bright)
|
||||
defer ct.ResetColor()
|
||||
|
||||
return fmt.Println(a...)
|
||||
}
|
||||
|
||||
// Printf calls fmt.Printf with foreground color set.
|
||||
func Printf(cl ct.Color, bright bool, format string, a ...interface{}) (n int, err error) {
|
||||
ct.Foreground(cl, bright)
|
||||
defer ct.ResetColor()
|
||||
|
||||
return fmt.Printf(format, a...)
|
||||
}
|
||||
|
||||
// Printfln calls fmt.Printf and add an extra new-line char with foreground color set.
|
||||
func Printfln(cl ct.Color, bright bool, format string, a ...interface{}) (n int, err error) {
|
||||
ct.Foreground(cl, bright)
|
||||
defer ct.ResetColor()
|
||||
|
||||
return fmt.Printf(format+"\n", a...)
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
module github.com/daviddengcn/go-colortext
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/golangplus/bytes v1.0.0 // indirect
|
||||
github.com/golangplus/testing v1.0.0
|
||||
)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 h1:7xqw01UYS+KCI25bMrPxwNYkSns2Db1ziQPpVq99FpE=
|
||||
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho=
|
||||
github.com/golangplus/bytes v1.0.0 h1:YQKBijBVMsBxIiXT4IEhlKR2zHohjEqPole4umyDX+c=
|
||||
github.com/golangplus/bytes v1.0.0/go.mod h1:AdRaCFwmc/00ZzELMWb01soso6W1R/++O1XL80yAn+A=
|
||||
github.com/golangplus/fmt v1.0.0 h1:FnUKtw86lXIPfBMc3FimNF3+ABcV+aH5F17OOitTN+E=
|
||||
github.com/golangplus/fmt v1.0.0/go.mod h1:zpM0OfbMCjPtd2qkTD/jX2MgiFCqklhSUFyDW44gVQE=
|
||||
github.com/golangplus/testing v1.0.0 h1:+ZeeiKZENNOMkTTELoSySazi+XaEhVO0mb+eanrSEUQ=
|
||||
github.com/golangplus/testing v1.0.0/go.mod h1:ZDreixUV3YzhoVraIDyOzHrr76p6NUh6k/pPg/Q3gYA=
|
||||
4
pkg/mod/github.com/dixonwille/wmenu@v4.0.2+incompatible/.gitignore
vendored
Normal file
4
pkg/mod/github.com/dixonwille/wmenu@v4.0.2+incompatible/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.imdone/
|
||||
*.out
|
||||
vendor/**
|
||||
!vendor/vendor.json
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
language: go
|
||||
go:
|
||||
- tip
|
||||
before_install:
|
||||
- go get -t -v ./...
|
||||
script:
|
||||
- go test -race -coverprofile=coverage.txt -covermode=atomic
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Will Dixon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
# WMenu[](https://travis-ci.org/dixonwille/wmenu) [](https://codecov.io/gh/dixonwille/wmenu)
|
||||
|
||||
Package wmenu creates menus for cli programs. It uses wlog for it's interface
|
||||
with the command line. It uses os.Stdin, os.Stdout, and os.Stderr with
|
||||
concurrency by default. wmenu allows you to change the color of the different
|
||||
parts of the menu. This package also creates it's own error structure so you can
|
||||
type assert if you need to. wmenu will validate all responses before calling any function. It will also figure out which function should be called so you don't have to.
|
||||
|
||||
[](https://asciinema.org/a/4lv3ash3ubtnsclindvzdf320)
|
||||
|
||||
## Import
|
||||
|
||||
I try and keep up with my tags. To use the version and stable it is recommended to use `govendor` or another vendoring tool that allows you to build your project for specific tags.
|
||||
|
||||
```sh
|
||||
govendor fetch github.com/dixonwille/wmenu@v4
|
||||
```
|
||||
|
||||
The above will grab the latest v4 at that time and mark it. It will then be stable for you to use.
|
||||
|
||||
I will try to support as many versions as possable but please be patient.
|
||||
|
||||
### V1.0.0 - Major Release [](https://goreportcard.com/report/gopkg.in/dixonwille/wmenu.v1) [](https://godoc.org/gopkg.in/dixonwille/wmenu.v1)
|
||||
|
||||
### V2.0.0 - Allowing an interface to be passed in for options [](https://goreportcard.com/report/gopkg.in/dixonwille/wmenu.v2) [](https://godoc.org/gopkg.in/dixonwille/wmenu.v2)
|
||||
|
||||
### V3.0.0 - Pass in the option to that option's function [](https://goreportcard.com/report/gopkg.in/dixonwille/wmenu.v3) [](https://godoc.org/gopkg.in/dixonwille/wmenu.v3)
|
||||
|
||||
### V4.0.0 - Now have an Action that supports multiple options [](https://goreportcard.com/report/gopkg.in/dixonwille/wmenu.v4) [](https://godoc.org/gopkg.in/dixonwille/wmenu.v4)
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
* Force single selection
|
||||
* Allow multiple selection
|
||||
* Change the delimiter
|
||||
* Change the color of different parts of the menu
|
||||
* Easily see which option(s) are default
|
||||
* Change the symbol used for default option(s)
|
||||
* Ask simple yes and no questions
|
||||
* Validate all responses before calling any functions
|
||||
* With yes and no can accept:
|
||||
* yes, Yes, YES, y, Y
|
||||
* no, No, NO, n, N
|
||||
* Figure out which Action should be called (Options, Default, or Multiple Action)
|
||||
* Re-ask question if invalid response up to a certain number of times
|
||||
* Can change max number of times to ask before failing output
|
||||
* Change reader and writer
|
||||
* Clear the screen whenever the menu is brought up
|
||||
* Has its own error structure so you can type assert menu errors
|
||||
|
||||
### V2 - Adds these Features
|
||||
|
||||
* Allowing any interface to be passed through for the options.
|
||||
|
||||
### V3 - Adds these Features
|
||||
|
||||
* Pass the option chosen to that options function
|
||||
|
||||
### V4 - Adds these Features
|
||||
|
||||
* Have one function for both single and multiple select. Allowing the user to an easier way of handeling the request.
|
||||
|
||||
## Usage
|
||||
This is a simple use of the package. (**NOTE: THIS IS A V4 SAMPLE**)
|
||||
|
||||
``` go
|
||||
menu := wmenu.NewMenu("What is your favorite food?")
|
||||
menu.Action(func (opts []wmenu.Opt) error {fmt.Printf(opts[0].Text + " is your favorite food."); return nil})
|
||||
menu.Option("Pizza", nil, true, nil)
|
||||
menu.Option("Ice Cream", nil, false, nil)
|
||||
menu.Option("Tacos", nil, false, func(opt wmenu.Opt) error {
|
||||
fmt.Printf("Tacos are great")
|
||||
})
|
||||
err := menu.Run()
|
||||
if err != nil{
|
||||
log.Fatal(err)
|
||||
}
|
||||
```
|
||||
|
||||
The output would look like this:
|
||||
|
||||
```
|
||||
0) *Pizza
|
||||
1) Ice Cream
|
||||
2) Tacos
|
||||
What is your favorite food?
|
||||
```
|
||||
|
||||
If the user just presses `[Enter]` then the option(s) with the `*` will be selected. This indicates that it is a default function. If they choose `1` then they would see `Ice Cream is your favorite food.`. This used the Action's function because the option selected didn't have a function along with it. But if they choose `2` they would see `Tacos are great`. That option did have a function with it which take precedence over Action.
|
||||
|
||||
You can you also use:
|
||||
|
||||
``` go
|
||||
menu.AllowMultiple()
|
||||
```
|
||||
|
||||
This will allow the user to select multiple options. The default delimiter is a `[space]`, but can be changed by using:
|
||||
|
||||
``` go
|
||||
menu.SetSeperator("some string")
|
||||
```
|
||||
|
||||
Another feature is the ability to ask yes or no questions.
|
||||
|
||||
``` go
|
||||
menu.IsYesNo(0)
|
||||
```
|
||||
|
||||
This will remove any options previously added options and hide the ones used for the menu. It will simply just ask yes or no. Menu will parse and validate the response for you. This option will always call the Action's function and pass in the option that was selected.
|
||||
|
||||
## V3+ - Release
|
||||
Allows the user to pass anything for the value so it can be retrieved later in the function. The following is to show case the power of this.
|
||||
|
||||
> The following was written in V3 but the concept holds for V4. V4 just changed `actFunc` to be `func([]wmenu.Opt) error` instead.
|
||||
|
||||
```go
|
||||
type NameEntity struct {
|
||||
FirstName string
|
||||
LastName string
|
||||
}
|
||||
|
||||
optFunc := func(opt wmenu.Opt) error {
|
||||
fmt.Println("Option 0 was chosen.")
|
||||
return nil
|
||||
}
|
||||
actFunc := func(opt wmenu.Opt) error {
|
||||
name, ok := opt.Value.(NameEntity)
|
||||
if !ok {
|
||||
log.Fatal("Could not cast option's value to NameEntity")
|
||||
}
|
||||
fmt.Printf("%s has an id of %d.\n", opt.Text, opt.ID)
|
||||
fmt.Printf("Hello, %s %s.\n", name.FirstName, name.LastName)
|
||||
return nil
|
||||
}
|
||||
menu := NewMenu("Choose an option.")
|
||||
menu.ChangeReaderWriter(reader, os.Stdout, os.Stderr)
|
||||
menu.Action(actFunc)
|
||||
menu.Option("Option 0", NameEntity{"Bill", "Bob"}, true, optFunc)
|
||||
menu.Option("Option 1", NameEntity{"John", "Doe"}, false, nil)
|
||||
menu.Option("Option 2", NameEntity{"Jane", "Doe"}, false, nil)
|
||||
err := menu.Run()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
```
|
||||
|
||||
The immediate output would be:
|
||||
|
||||
```
|
||||
Output:
|
||||
0) *Option 0
|
||||
1) Option 1
|
||||
2) Option 2
|
||||
Choose an option.
|
||||
```
|
||||
|
||||
Now if the user pushes `[ENTER]` the output would be `Options 0 was chosen.`. But now if either option 1 or 2 were chosen it would cast the options value to a NameEntity allowing the function to be able to gather both the first name and last name of the NameEntity. If you want though you can just pass in `nil` as the value or even a string (`"hello"`) since both of these implement the empty interface required by value. Just make sure to cast the values so you can use them appropriately.
|
||||
|
||||
## Further Reading
|
||||
This whole package has been documented and has a few examples in:
|
||||
* [godocs V1](https://godoc.org/gopkg.in/dixonwille/wmenu.v1)
|
||||
* [godocs V2](https://godoc.org/gopkg.in/dixonwille/wmenu.v2)
|
||||
* [godocs V3](https://godoc.org/gopkg.in/dixonwille/wmenu.v3)
|
||||
* [godocs V4](https://godoc.org/gopkg.in/dixonwille/wmenu.v4)
|
||||
|
||||
You should read the docs to find all functions and structures at your finger tips.
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package wmenu
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var clear map[string]func()
|
||||
|
||||
func init() {
|
||||
clear = make(map[string]func())
|
||||
clear["linux"] = func() {
|
||||
cmd := exec.Command("clear")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Run()
|
||||
}
|
||||
clear["darwin"] = func() {
|
||||
cmd := exec.Command("clear")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Run()
|
||||
}
|
||||
clear["windows"] = func() {
|
||||
cmd := exec.Command("cmd", "/c", "cls")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Run()
|
||||
}
|
||||
}
|
||||
|
||||
//Clear simply clears the command line interface (os.Stdout only).
|
||||
func Clear() {
|
||||
value, ok := clear[runtime.GOOS]
|
||||
if ok {
|
||||
value()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package wmenu
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestClear(t *testing.T) {
|
||||
Clear()
|
||||
}
|
||||
|
||||
func TestClearLinux(t *testing.T) {
|
||||
clearOs("linux")
|
||||
}
|
||||
|
||||
func TestClearDarwin(t *testing.T) {
|
||||
clearOs("darwin")
|
||||
}
|
||||
|
||||
func TestClearWindows(t *testing.T) {
|
||||
clearOs("windows")
|
||||
}
|
||||
|
||||
func clearOs(os string) {
|
||||
value, ok := clear[os]
|
||||
if ok {
|
||||
value()
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user