Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(options): add a new option --default/-d #41

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func (c *Config) Run(opts *options.Options) (*render.Template, error) {
if err != nil {
return nil, err
}

if opts.Default {
return c.defaultTmpl, nil
}
// find the given template
if len(opts.Template) > 0 {
if opts.Template == c.defaultTmpl.Name {
Expand Down
2 changes: 2 additions & 0 deletions internal/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type Options struct {
DryRun bool
NoTTY bool
Default bool
Template string
GitOptions *git.Options
}
Expand All @@ -25,6 +26,7 @@ func (o *Options) AddFlags(f *pflag.FlagSet) {

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.")
f.StringVarP(&o.Template, "template", "t", o.Template, "template name to use when multiple templates exist.")
f.BoolVarP(&o.Default, "default", "d", o.Default, "use the default template, '--default' has a higher priority than '--template'.")
f.BoolVar(&o.NoTTY, "no-tty", o.NoTTY, "make sure that the TTY (terminal) is never used for any output.")

_ = f.MarkHidden("no-tty")
Expand Down
Loading