feat: add --sort [TYPE] flag (#78)

* feat(chglog): add --sort flag

* chore(sort): update README with --sort usage
This commit is contained in:
Sander Blue 2021-03-28 22:17:21 -05:00 committed by GitHub
parent 34b9d5c997
commit e523fd471a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 1 deletions

View file

@ -198,6 +198,7 @@ OPTIONS:
--jira-url value Jira URL [$JIRA_URL]
--jira-username value Jira username [$JIRA_USERNAME]
--jira-token value Jira token [$JIRA_TOKEN]
--sort value Specify how to sort tags; currently supports "date" or by "semver" (default: date)
--help, -h show help (default: false)
--version, -v print the version (default: false)

View file

@ -308,7 +308,7 @@ func (config *Config) Convert(ctx *CLIContext) *chglog.Config {
Options: &chglog.Options{
NextTag: ctx.NextTag,
TagFilterPattern: ctx.TagFilterPattern,
Sort: opts.Sort,
Sort: orValue(ctx.Sort, opts.Sort),
NoCaseSensitive: ctx.NoCaseSensitive,
Paths: ctx.Paths,
CommitFilters: opts.Commits.Filters,

View file

@ -24,6 +24,7 @@ type CLIContext struct {
JiraToken string
JiraURL string
Paths []string
Sort string
}
// InitContext ...

View file

@ -178,6 +178,13 @@ func CreateApp(actionFunc cli.ActionFunc) *cli.App {
EnvVars: []string{"JIRA_TOKEN"},
},
// sort
&cli.StringFlag{
Name: "sort",
Usage: "Specify how to sort tags; currently supports \"date\" or by \"semver\"",
DefaultText: "date",
},
// help & version
cli.HelpFlag,
cli.VersionFlag,
@ -240,6 +247,7 @@ func AppAction(c *cli.Context) error {
JiraToken: c.String("jira-token"),
JiraURL: c.String("jira-url"),
Paths: c.StringSlice("path"),
Sort: c.String("sort"),
},
fs,
NewConfigLoader(),