Skip to content

Commit 4239d34

Browse files
authored
feat(options): add a new option --default/-d (#41)
* feat(options): add a new option --default/-d * feat(options): add a new option --default/-t
1 parent 5beb4b8 commit 4239d34

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

internal/config/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func (c *Config) Run(opts *options.Options) (*render.Template, error) {
8585
if err != nil {
8686
return nil, err
8787
}
88+
89+
if opts.Default {
90+
return c.defaultTmpl, nil
91+
}
8892
// find the given template
8993
if len(opts.Template) > 0 {
9094
if opts.Template == c.defaultTmpl.Name {

internal/options/options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
type Options struct {
1010
DryRun bool
1111
NoTTY bool
12+
Default bool
1213
Template string
1314
GitOptions *git.Options
1415
}
@@ -25,6 +26,7 @@ func (o *Options) AddFlags(f *pflag.FlagSet) {
2526

2627
f.BoolVar(&o.DryRun, "dry-run", o.DryRun, "you can use the --dry-run flag to preview the message that would be committed, without really submitting it.")
2728
f.StringVarP(&o.Template, "template", "t", o.Template, "template name to use when multiple templates exist.")
29+
f.BoolVarP(&o.Default, "default", "d", o.Default, "use the default template, '--default' has a higher priority than '--template'.")
2830
f.BoolVar(&o.NoTTY, "no-tty", o.NoTTY, "make sure that the TTY (terminal) is never used for any output.")
2931

3032
_ = f.MarkHidden("no-tty")

0 commit comments

Comments
 (0)