summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRohan Verma <hello@rohanverma.net>2018-10-24 14:16:50 +0530
committerRohan Verma <hello@rohanverma.net>2018-10-24 14:16:50 +0530
commitd23f52c45d98ac058eb3502e3ee8354e431cab0e (patch)
treef85a0faac2bcacc5f792f114d504a1531977fa87
parentf8832c5f62c562ba0a1c18723c7a12f4e510cf94 (diff)
feat: use pflag instead of flag
-rw-r--r--go.mod1
-rw-r--r--go.sum2
-rw-r--r--up.go16
3 files changed, 7 insertions, 12 deletions
diff --git a/go.mod b/go.mod
index 01099d1..ecbfe90 100644
--- a/go.mod
+++ b/go.mod
@@ -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
)
diff --git a/go.sum b/go.sum
index bf01bbb..281ff67 100644
--- a/go.sum
+++ b/go.sum
@@ -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=
diff --git a/up.go b/up.go
index 74bea92..498e758 100644
--- a/up.go
+++ b/up.go
@@ -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.)