diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-08-06 22:11:10 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-08-06 22:11:10 +0200 |
commit | 6afe1275b43542f8c418d8966f0e09fbd90f6b29 (patch) | |
tree | 34b0a843a15ef42022c19b5c1ce397785eb83909 | |
parent | d19f48af677d13985cdf4e96d18d463bd8518307 (diff) |
cmd: Remove go-flags dependency
-rw-r--r-- | cmd/lftpq/main.go | 33 | ||||
-rw-r--r-- | go.mod | 4 |
2 files changed, 19 insertions, 18 deletions
diff --git a/cmd/lftpq/main.go b/cmd/lftpq/main.go index af92a9a..3183d75 100644 --- a/cmd/lftpq/main.go +++ b/cmd/lftpq/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "io" "os" @@ -8,8 +9,6 @@ import ( "path/filepath" "syscall" - flags "github.com/jessevdk/go-flags" - "github.com/mpolden/lftpq/lftp" "github.com/mpolden/lftpq/queue" ) @@ -19,14 +18,14 @@ type lister interface { } type CLI struct { - Config string `short:"f" long:"config" description:"Path to config" value-name:"FILE" default:"~/.lftpqrc"` - Dryrun bool `short:"n" long:"dryrun" description:"Print queue and exit"` - Format string `short:"F" long:"format" description:"Format to use in dryrun mode" choice:"lftp" choice:"json" default:"lftp"` - Test bool `short:"t" long:"test" description:"Test and print config"` - Quiet bool `short:"q" long:"quiet" description:"Do not print output from lftp"` - Import bool `short:"i" long:"import" description:"Build queues from stdin"` - LocalDir string `short:"l" long:"local-dir" description:"Override local dir for this run" value-name:"NAME"` - LftpPath string `short:"p" long:"lftp" description:"Path to lftp program" value-name:"NAME" default:"lftp"` + Config string + Dryrun bool + Format string + Test bool + Quiet bool + Import bool + LocalDir string + LftpPath string consumer queue.Consumer lister lister stderr io.Writer @@ -162,11 +161,15 @@ func main() { cli.stderr = os.Stderr cli.stdout = os.Stdout cli.stdin = os.Stdin - p := flags.NewParser(cli, flags.HelpFlag|flags.PassDoubleDash) - if _, err := p.Parse(); err != nil { - cli.printf("%s\n", err) - os.Exit(1) - } + flag.StringVar(&cli.Config, "f", "~/.lftpqrc", "Path to config") + flag.BoolVar(&cli.Dryrun, "n", false, "Print queue and exit") + flag.StringVar(&cli.Format, "F", "lftp", "Format to use in dry-run mode") + flag.BoolVar(&cli.Test, "t", false, "Test and print config") + flag.BoolVar(&cli.Quiet, "q", false, "Do not print output from lftp") + flag.BoolVar(&cli.Import, "i", false, "Build queues from stdin") + flag.StringVar(&cli.LocalDir, "l", "", "Override local dir for this run") + flag.StringVar(&cli.LftpPath, "p", "lftp", "Path to lftp program") + flag.Parse() client := lftp.Client{Path: cli.LftpPath, InheritIO: !cli.Quiet} cli.lister = &client cli.consumer = &client @@ -1,5 +1,3 @@ module github.com/mpolden/lftpq -go 1.13 - -require github.com/jessevdk/go-flags v1.4.0 +go 1.14 |