refactor: accept both write and diff
parent
074f0c3009
commit
338e835b9c
|
@ -1,6 +1,8 @@
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,14 +27,14 @@ func (a *action) getFlags(c *cli.Context) {
|
||||||
func (a *action) Run(c *cli.Context) error {
|
func (a *action) Run(c *cli.Context) error {
|
||||||
a.getFlags(c)
|
a.getFlags(c)
|
||||||
|
|
||||||
if !a.flags.write &&
|
// No flag is set
|
||||||
|
if !a.flags.list &&
|
||||||
|
!a.flags.write &&
|
||||||
!a.flags.diff {
|
!a.flags.diff {
|
||||||
if err := a.RunHelp(c); err != nil {
|
return a.RunHelp(c)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(c.Args().Slice())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,10 @@ const (
|
||||||
flagListUsage = "list files will be changed"
|
flagListUsage = "list files will be changed"
|
||||||
|
|
||||||
flagWriteName = "write"
|
flagWriteName = "write"
|
||||||
flagWriteUsage = "actually write changes to (source) files, conflicts with -d, only one of -w or -d can be used"
|
flagWriteUsage = "actually write changes to (source) files"
|
||||||
|
|
||||||
// If both write and diff is exist
|
|
||||||
// Choose diff
|
|
||||||
flagDiffName = "diff"
|
flagDiffName = "diff"
|
||||||
flagDiffUsage = "show diff instead of writing changes"
|
flagDiffUsage = "show diff"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in New Issue