mirror of
https://github.com/directorz/mailfull-go.git
synced 2025-12-19 18:47:05 +00:00
Implement to parse -n flag #7
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
@@ -11,3 +14,17 @@ type Meta struct {
|
||||
SubCmdName string
|
||||
Version string
|
||||
}
|
||||
|
||||
// noCommitFlag returns true if `pargs` has "-n" flag.
|
||||
// `pargs` is overwrites with non-flag arguments.
|
||||
func noCommitFlag(pargs *[]string) (bool, error) {
|
||||
nFlag := false
|
||||
|
||||
flagSet := flag.NewFlagSet("", flag.ContinueOnError)
|
||||
flagSet.SetOutput(&bytes.Buffer{})
|
||||
flagSet.BoolVar(&nFlag, "n", nFlag, "")
|
||||
err := flagSet.Parse(*pargs)
|
||||
*pargs = flagSet.Args()
|
||||
|
||||
return nFlag, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user