refactor: accept both write and diff

main
sudo pacman -Syu 2022-11-25 00:10:14 +07:00
parent 074f0c3009
commit 338e835b9c
No known key found for this signature in database
GPG Key ID: D6CB5C6C567C47B0
2 changed files with 10 additions and 10 deletions

View File

@ -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 nil
return a.RunHelp(c)
}
fmt.Println(c.Args().Slice())
return nil
}

View File

@ -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 (