Skip to content

Commit

Permalink
refactor: extract common options
Browse files Browse the repository at this point in the history
  • Loading branch information
ShuheiKubota committed Apr 14, 2024
1 parent 063096a commit 00e0aa5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2
github.com/antchfx/xmlquery v1.4.0
github.com/shu-go/ennet v0.4.3
github.com/shu-go/gli/v2 v2.1.1
github.com/shu-go/gli/v2 v2.2.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ github.com/shu-go/cliparser v0.2.4 h1:6RJjRRy2aTx0f+hAX8gp9Lf5+w3Y7fcvvorWmXcmdG
github.com/shu-go/cliparser v0.2.4/go.mod h1:oX+xgwUi9B2OzBFudKc5ayoqWhlVAbuN67rAqyWvvQ4=
github.com/shu-go/ennet v0.4.3 h1:1QARqotp0GrJtyv0E7rbc1nk8G1KGZFqYYMpFwjh6Fw=
github.com/shu-go/ennet v0.4.3/go.mod h1:EqlfDAcg+jXfNfpm11p6SvGdN2+PLmhEjxn21aIbe4E=
github.com/shu-go/gli/v2 v2.1.1 h1:K3nvPivp3OcnWCKbEZmJLLxk8RrT9Os3YqAP4ZUqV+8=
github.com/shu-go/gli/v2 v2.1.1/go.mod h1:zx0BtgXdLVRSaQUla1Q5XLfPHyyA0HLipeD81A0EkHs=
github.com/shu-go/gli/v2 v2.2.0 h1:WSFJnPuNQHyNKZdyl6HF3BpzqyszVj0GR/SMHuea8qE=
github.com/shu-go/gli/v2 v2.2.0/go.mod h1:zx0BtgXdLVRSaQUla1Q5XLfPHyyA0HLipeD81A0EkHs=
github.com/shu-go/gotwant v0.0.0-20190920074605-b4f19c0bac91 h1:nwDc3kHbf9scf1UZIWiWw5tZF3Z4yOJAMjNN+kYXJwE=
github.com/shu-go/gotwant v0.0.0-20190920074605-b4f19c0bac91/go.mod h1:FZepfqvib0mXjHiaQPTv0RUD5QMpMA/FHLfBQjZRRQg=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
14 changes: 8 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ type globalCmd struct {
Add addCmd
}

type common struct {
Indent int `cli:"indent=NUMBER" default:"4"`
EmptyElement bool `cli:"empty" default:"true"`
}

type replaceCmd struct {
_ struct{} `help:"--xpath //* --value newvalue hoge.xml"`

XPath string `cli:"xpath" required:"true"`
Value string `cli:"value" required:"true"`

Indent int `cli:"indent=NUMBER" default:"4"`
EmptyElement bool `cli:"empty" default:"true"`
common
}

func (c replaceCmd) Run(args []string) error {
Expand Down Expand Up @@ -76,8 +80,7 @@ type deleteCmd struct {

XPath string `cli:"xpath" required:"true"`

Indent int `cli:"indent=NUMBER" default:"4"`
EmptyElement bool `cli:"empty" default:"true"`
common
}

func (c deleteCmd) Run(args []string) error {
Expand Down Expand Up @@ -131,8 +134,7 @@ type addCmd struct {

Sibling bool `cli:"sibling" default:"false" help:"as a LAST sibling"`

Indent int `cli:"indent=NUMBER" default:"4"`
EmptyElement bool `cli:"empty" default:"true"`
common
}

func (c addCmd) Before() error {
Expand Down

0 comments on commit 00e0aa5

Please sign in to comment.