diff --git a/README.md b/README.md index 65012e6..198c702 100644 --- a/README.md +++ b/README.md @@ -133,20 +133,30 @@ $ release_tools next_version 1.0.1+1 # 1.1.0+2 ``` -If you don't want this behavior, pass the `--freezeBuild` flag. +If you don't want this behavior, pass the `--freeze-build` flag. ```sh -$ release_tools next_version --freezeBuild 1.0.1+1 +$ release_tools next_version --freeze-build 1.0.1+1 # 1.1.0+1 ``` -To output just the version without the build number, pass the `--noBuild` flag. +To output just the version without the build number, pass the `--no-build` flag. ```sh -$ release_tools next_version --noBuild 1.0.1+1 +$ release_tools next_version --no-build 1.0.1+1 # 1.1.0 ``` +If you want to ensure that the next version is a major version and not a +pre-release, use the `--ensure-major` flag. + +```sh +$ release_tools next_version 0.2.3 +# 0.4.3 +$ release_tools next_version --ensure-major 0.2.3 +# 1.0.0 +``` + ### should_release The following will print 'yes' to stdout if there are releasable commits, or diff --git a/lib/next_version_command.dart b/lib/next_version_command.dart index e36b4ba..dd23443 100644 --- a/lib/next_version_command.dart +++ b/lib/next_version_command.dart @@ -38,7 +38,9 @@ class NextVersionCommand extends ReleaseToolsCommand release_tools next_version # will check version on pubspec.yaml release_tools next_version 2.0.1 release_tools next_version --from=3682c64 2.0.1 -release_tools next_version --ensureMajor 0.2.5 # always version >= 1.0.0 +release_tools next_version --ensure-major 0.2.5 # always version >= 1.0.0 +release_tools next_version 2.1.3+24 # 2.1.4+25 +release_tools next_version --no-build 2.1.3+24 # 2.1.4 ''', ); @@ -53,19 +55,22 @@ release_tools next_version --ensureMajor 0.2.5 # always version >= 1.0.0 void incrementBuildFromOption() { argParser.addFlag( - 'freezeBuild', + 'freeze-build', abbr: 'b', help: 'Do not increment build number', + aliases: ['freezeBuild'], ); argParser.addFlag( - 'noBuild', + 'no-build', abbr: 'n', help: 'Do not include build number in output', + aliases: ['noBuild'], ); argParser.addFlag( - 'ensureMajor', + 'ensure-major', abbr: 'm', help: 'Ensure next version >= 1.0.0', + aliases: ['ensureMajor'], ); } @@ -73,13 +78,13 @@ release_tools next_version --ensureMajor 0.2.5 # always version >= 1.0.0 Future run() async { final currentVersion = await getVersionFromArgsOrPubspec(); final args = ensureArgResults(); - final incrementBuild = !(args['freezeBuild'] as bool); + final incrementBuild = !(args['freeze-build'] as bool); final theNextVersion = await getNextVersionFromString( await getCommits(), currentVersion, incrementBuild: incrementBuild, - noBuild: args['noBuild'] as bool, - ensureMajor: args['ensureMajor'] as bool, + noBuild: args['no-build'] as bool, + ensureMajor: args['ensure-major'] as bool, ); printer.println(theNextVersion); } diff --git a/test/next_version_command_test.dart b/test/next_version_command_test.dart index e25c3cc..35cd480 100644 --- a/test/next_version_command_test.dart +++ b/test/next_version_command_test.dart @@ -209,13 +209,13 @@ void main() { } final args = [command]; if (data.freezeBuild) { - args.add('--freezeBuild'); + args.add('--freeze-build'); } if (data.noBuild) { - args.add('--noBuild'); + args.add('--no-build'); } if (data.ensureMajor) { - args.add('--ensureMajor'); + args.add('--ensure-major'); } args.add(version); await runner.run(args);