refactor: accept both write and diff
parent
074f0c3009
commit
338e835b9c
|
@ -1,6 +1,8 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
@ -25,14 +27,14 @@ func (a *action) getFlags(c *cli.Context) {
|
|||
func (a *action) Run(c *cli.Context) error {
|
||||
a.getFlags(c)
|
||||
|
||||
if !a.flags.write &&
|
||||
// No flag is set
|
||||
if !a.flags.list &&
|
||||
!a.flags.write &&
|
||||
!a.flags.diff {
|
||||
if err := a.RunHelp(c); err != nil {
|
||||
return err
|
||||
return a.RunHelp(c)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
fmt.Println(c.Args().Slice())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -16,12 +16,10 @@ const (
|
|||
flagListUsage = "list files will be changed"
|
||||
|
||||
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"
|
||||
flagDiffUsage = "show diff instead of writing changes"
|
||||
flagDiffUsage = "show diff"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
Loading…
Reference in New Issue