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
# 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)
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
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

View File

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

View File

@ -19,12 +19,16 @@ import (
)
func (a *action) RunGenerate(c *cli.Context) error {
// Show help if there is nothing
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)
}
a.getFlags(c)
} else {
// TODO: add interactive mode
}
commits, err := a.getCommits()
if err != nil {

View File

@ -12,9 +12,9 @@ const (
usage = "generate changelog from conventional commits"
flagVerbose = "verbose"
flagVersion = "version"
flagFrom = "from"
flagTo = "to"
flagVersion = "version"
flagScope = "scope"
flagRepository = "repository"
flagOutput = "output"
@ -27,9 +27,9 @@ const (
usageGenerate = "generate changelog"
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"
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"
usageRepository = "`REPOSITORY` directory path"
usageOutput = "`OUTPUT` directory path"
@ -66,6 +66,10 @@ func NewApp() *App {
Aliases: aliasVerbose,
Usage: usageVerbose,
},
&cli.StringFlag{
Name: flagVersion,
Usage: usageVersion,
},
&cli.StringFlag{
Name: flagFrom,
Usage: usageFrom,
@ -74,10 +78,6 @@ func NewApp() *App {
Name: flagTo,
Usage: usageTo,
},
&cli.StringFlag{
Name: flagVersion,
Usage: usageVersion,
},
&cli.StringSliceFlag{
Name: flagScope,
Usage: usageScope,