chore: put version before from, to

main
sudo pacman -Syu 2022-02-07 22:52:35 +07:00
parent f6240686ec
commit 3f0c224c79
4 changed files with 20 additions and 16 deletions

View File

@ -41,13 +41,13 @@ changeloguru --help
changeloguru generate --version v1.0.0 changeloguru generate --version v1.0.0
# Generate changelog v2.0.0 from HEAD to tag v1.0.0 # Generate changelog v2.0.0 from HEAD to tag v1.0.0
changeloguru generate --to v1.0.0 --version v2.0.0 changeloguru generate --version v2.0.0 --to v1.0.0
# Generate changelog in dry run mode (without changing anything) # Generate changelog in dry run mode (without changing anything)
changeloguru generate --to v1.0.0 --version v2.0.0 --dry-run changeloguru generate --version v2.0.0 --to v1.0.0 --dry-run
# Generate changelog only for scope # Generate changelog only for scope
changeloguru generate --to v1.0.0 --version v2.0.0 --scope projectA --scope projectB changeloguru generate --version v2.0.0 --to v1.0.0 --scope projectA --scope projectB
``` ```
## Thanks ## Thanks

View File

@ -39,9 +39,9 @@ func (a *action) RunHelp(c *cli.Context) error {
func (a *action) getFlags(c *cli.Context) { func (a *action) getFlags(c *cli.Context) {
a.flags.verbose = c.Bool(flagVerbose) a.flags.verbose = c.Bool(flagVerbose)
a.flags.version = c.String(flagVersion)
a.flags.from = c.String(flagFrom) a.flags.from = c.String(flagFrom)
a.flags.to = c.String(flagTo) a.flags.to = c.String(flagTo)
a.flags.version = c.String(flagVersion)
a.flags.scopes = make(map[string]struct{}) a.flags.scopes = make(map[string]struct{})
for _, scope := range c.StringSlice(flagScope) { for _, scope := range c.StringSlice(flagScope) {

View File

@ -19,13 +19,17 @@ import (
) )
func (a *action) RunGenerate(c *cli.Context) error { func (a *action) RunGenerate(c *cli.Context) error {
// Show help if there is nothing
if c.NumFlags() == 0 {
return cli.ShowAppHelp(c)
}
a.getFlags(c) a.getFlags(c)
if !a.flags.interactive {
// Show help if there is nothing and not in interactive mode
if c.NumFlags() == 0 {
return cli.ShowAppHelp(c)
}
} else {
// TODO: add interactive mode
}
commits, err := a.getCommits() commits, err := a.getCommits()
if err != nil { if err != nil {
return err return err

View File

@ -12,9 +12,9 @@ const (
usage = "generate changelog from conventional commits" usage = "generate changelog from conventional commits"
flagVerbose = "verbose" flagVerbose = "verbose"
flagVersion = "version"
flagFrom = "from" flagFrom = "from"
flagTo = "to" flagTo = "to"
flagVersion = "version"
flagScope = "scope" flagScope = "scope"
flagRepository = "repository" flagRepository = "repository"
flagOutput = "output" flagOutput = "output"
@ -27,9 +27,9 @@ const (
usageGenerate = "generate changelog" usageGenerate = "generate changelog"
usageVerbose = "show what is going on" usageVerbose = "show what is going on"
usageFrom = "from `COMMIT`, which is kinda new commit"
usageTo = "to `COMMIT`, which is kinda old commit"
usageVersion = "`VERSION` to generate, follow Semantic Versioning" usageVersion = "`VERSION` to generate, follow Semantic Versioning"
usageFrom = "from `COMMIT`, which is kinda new commit, default is latest commit"
usageTo = "to `COMMIT`, which is kinda old commit, default is oldest commit"
usageScope = "scope to generate" usageScope = "scope to generate"
usageRepository = "`REPOSITORY` directory path" usageRepository = "`REPOSITORY` directory path"
usageOutput = "`OUTPUT` directory path" usageOutput = "`OUTPUT` directory path"
@ -66,6 +66,10 @@ func NewApp() *App {
Aliases: aliasVerbose, Aliases: aliasVerbose,
Usage: usageVerbose, Usage: usageVerbose,
}, },
&cli.StringFlag{
Name: flagVersion,
Usage: usageVersion,
},
&cli.StringFlag{ &cli.StringFlag{
Name: flagFrom, Name: flagFrom,
Usage: usageFrom, Usage: usageFrom,
@ -74,10 +78,6 @@ func NewApp() *App {
Name: flagTo, Name: flagTo,
Usage: usageTo, Usage: usageTo,
}, },
&cli.StringFlag{
Name: flagVersion,
Usage: usageVersion,
},
&cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: flagScope, Name: flagScope,
Usage: usageScope, Usage: usageScope,