Skip to content

Commit

Permalink
feat(next_version): use dash-case for flags
Browse files Browse the repository at this point in the history
Instead of `--noBuild`, use `--no-build`.
  • Loading branch information
asartalo committed Mar 29, 2024
1 parent b0d56f0 commit d31d7b2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 12 additions & 7 deletions lib/next_version_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
''',
);

Expand All @@ -53,33 +55,36 @@ 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'],
);
}

@override
Future<void> 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);
}
Expand Down
6 changes: 3 additions & 3 deletions test/next_version_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d31d7b2

Please sign in to comment.