mirror of
https://github.com/byReqz/go-etcher.git
synced 2024-11-21 14:33:14 +00:00
add autocompleting prompt to getdest and getpath
This commit is contained in:
parent
7538896d21
commit
79e7417126
2
go.mod
2
go.mod
@ -9,6 +9,8 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/JoaoDanielRufino/go-input-autocomplete v1.0.4 // indirect
|
||||
github.com/eiannone/keyboard v0.0.0-20200508000154-caf4b762e807 // indirect
|
||||
github.com/mattn/go-colorable v0.1.9 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
||||
|
5
go.sum
5
go.sum
@ -1,8 +1,12 @@
|
||||
github.com/JoaoDanielRufino/go-input-autocomplete v1.0.4 h1:ZsgP08f77C1Hizi5pfB9xNBG+d605s0z+PWuI5KLEEk=
|
||||
github.com/JoaoDanielRufino/go-input-autocomplete v1.0.4/go.mod h1:tB42IGOd4W3hzlAcw8JWf0mMnu94q4tPsjhT24MbcB4=
|
||||
github.com/briandowns/spinner v1.18.0 h1:SJs0maNOs4FqhBwiJ3Gr7Z1D39/rukIVGQvpNZVHVcM=
|
||||
github.com/briandowns/spinner v1.18.0/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/eiannone/keyboard v0.0.0-20200508000154-caf4b762e807 h1:jdjd5e68T4R/j4PWxfZqcKY8KtT9oo8IPNVuV4bSXDQ=
|
||||
github.com/eiannone/keyboard v0.0.0-20200508000154-caf4b762e807/go.mod h1:Xoiu5VdKMvbRgHuY7+z64lhu/7lvax/22nzASF6GrO8=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
@ -35,6 +39,7 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200806125547-5acd03effb82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
10
main.go
10
main.go
@ -10,6 +10,7 @@ import (
|
||||
"github.com/fatih/color"
|
||||
"github.com/briandowns/spinner"
|
||||
flag "github.com/spf13/pflag"
|
||||
ac "github.com/JoaoDanielRufino/go-input-autocomplete"
|
||||
)
|
||||
|
||||
var device string
|
||||
@ -24,9 +25,7 @@ func init() {
|
||||
}
|
||||
|
||||
func GetPath() string {
|
||||
fmt.Print("[ ", color.YellowString("i"), " ] Please input your image file: ")
|
||||
var path string
|
||||
_, err := fmt.Scanln(&path)
|
||||
path, err := ac.Read("[ " + color.YellowString("i") + " ] Please input your image file: ")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -42,9 +41,7 @@ func GetPath() string {
|
||||
}
|
||||
|
||||
func GetDest() string {
|
||||
fmt.Print("[ ", color.YellowString("i"), " ] Please input destination: ")
|
||||
var dest string
|
||||
_, err := fmt.Scanln(&dest)
|
||||
dest, err := ac.Read("[ " + color.YellowString("i") + " ] Please input destination: ")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -62,7 +59,6 @@ func GetDest() string {
|
||||
func WriteImage(image *os.File, target *os.File, size int64) (int64, error) {
|
||||
bar := progressbar.NewOptions(int(size),
|
||||
progressbar.OptionSetWriter(os.Stderr),
|
||||
// progressbar.OptionEnableColorCodes(true),
|
||||
progressbar.OptionShowBytes(true),
|
||||
progressbar.OptionSetWidth(25),
|
||||
progressbar.OptionSetDescription("Writing image file..."),
|
||||
|
Loading…
Reference in New Issue
Block a user