Skip to content

Commit 5f52906

Browse files
authored
feat: Refactor Part5 (#11)
1 parent 7ed1522 commit 5f52906

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

internal/git/options.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package git
2+
3+
import "github.com/spf13/pflag"
4+
5+
type Options struct {
6+
SignOff bool
7+
Add bool
8+
}
9+
10+
func NewOptions() *Options {
11+
return &Options{
12+
SignOff: false,
13+
Add: false,
14+
}
15+
}
16+
17+
func (o *Options) AddFlags(f *pflag.FlagSet) {
18+
f.BoolVarP(&o.SignOff, "signoff", "s", o.SignOff, "Add a Signed-off-by trailer by the committer at the end of the commit log message.")
19+
f.BoolVarP(&o.Add, "add", "a", o.Add, "Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.")
20+
}

internal/options/options.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package options
2+
3+
import (
4+
"github.com/spf13/pflag"
5+
6+
"github.com/shipengqi/commitizen/internal/git"
7+
)
8+
9+
type Options struct {
10+
GitOptions *git.Options
11+
}
12+
13+
func New() *Options {
14+
return &Options{
15+
GitOptions: git.NewOptions(),
16+
}
17+
}
18+
19+
func (o *Options) AddFlags(f *pflag.FlagSet) {
20+
o.GitOptions.AddFlags(f)
21+
}

0 commit comments

Comments
 (0)