diff options
author | Rohan Verma <hello@rohanverma.net> | 2018-10-24 14:16:50 +0530 |
---|---|---|
committer | Rohan Verma <hello@rohanverma.net> | 2018-10-24 14:16:50 +0530 |
commit | d23f52c45d98ac058eb3502e3ee8354e431cab0e (patch) | |
tree | f85a0faac2bcacc5f792f114d504a1531977fa87 | |
parent | f8832c5f62c562ba0a1c18723c7a12f4e510cf94 (diff) |
feat: use pflag instead of flag
-rw-r--r-- | go.mod | 1 | ||||
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | up.go | 16 |
3 files changed, 7 insertions, 12 deletions
@@ -6,5 +6,6 @@ require ( github.com/lucasb-eyer/go-colorful v0.0.0-20170903184257-231272389856 github.com/mattn/go-isatty v0.0.3 github.com/mattn/go-runewidth v0.0.2 + github.com/spf13/pflag v1.0.3 golang.org/x/text v0.0.0-20171214130843-f21a4dfb5e38 ) @@ -8,5 +8,7 @@ github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= golang.org/x/text v0.0.0-20171214130843-f21a4dfb5e38 h1:yr7ItWHARpqySNZjEh5mPMHrw3xPR9tMnomFZVcO1mQ= golang.org/x/text v0.0.0-20171214130843-f21a4dfb5e38/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -21,7 +21,6 @@ import ( "bufio" "bytes" "context" - "flag" "fmt" "io" "io/ioutil" @@ -30,6 +29,8 @@ import ( "os/exec" "sync" + flag "github.com/spf13/pflag" + "github.com/gdamore/tcell" "github.com/mattn/go-isatty" ) @@ -64,20 +65,15 @@ import ( // Flag Settings var ( - debugMode bool + debugMode = flag.Bool("debug", false, "debug mode") ) -func init() { - flag.BoolVar(&debugMode, "debug", false, "debug mode") - flag.BoolVar(&debugMode, "d", false, "debug mode (shorthand)") -} - func main() { // Handle command-line flags flag.Parse() log.SetOutput(ioutil.Discard) - if debugMode { + if *debugMode { debug, err := os.Create("up.debug") if err != nil { die(err.Error()) @@ -182,10 +178,6 @@ func main() { } } -func parseFlags() { - -} - func initTUI() tcell.Screen { // TODO: Without below block, we'd hang when nothing is piped on input (see // github.com/peco/peco, mattn/gof, fzf, etc.) |