Skip to content

Commit

Permalink
chore(mason_logger): v0.2.0 (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Oct 13, 2022
1 parent 8adaa25 commit 46e8014
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 24 deletions.
27 changes: 27 additions & 0 deletions packages/mason_logger/CHANGELOG.md
@@ -1,3 +1,30 @@
# 0.2.0

- **BREAKING** feat: add generic support to `chooseOne` and `chooseAny`

```dart
enum Shape { square, circle, triangle}
void main() {
final logger = Logger();
final shape = logger.chooseOne<Shape>(
'What is your favorite shape?',
choices: Shape.values,
display: (shape) => '${shape.name}',
);
logger.info('You chose: $shape');
final shapes = logger.chooseAny<Shape>(
'Or did you want to choose multiples?',
choices: Shape.values,
defaultValues: [shape],
display: (shape) => '${shape.name}',
);
logger.info('You chose: $shapes');
}
```

# 0.1.4

- feat: add `ProgressOptions` API
Expand Down
37 changes: 16 additions & 21 deletions packages/mason_logger/example/main.dart
@@ -1,11 +1,6 @@
import 'package:mason_logger/mason_logger.dart';

enum Shape {
square,
circle,
triangle,
diamond,
}
enum Shape { square, circle, triangle }

Future<void> main() async {
final logger = Logger(level: Level.verbose)
Expand All @@ -32,6 +27,21 @@ Future<void> main() async {

logger.info('Awesome, $desserts it is!');

final shape = logger.chooseOne<Shape>(
'What is your favorite shape?',
choices: Shape.values,
display: (shape) => 'Is it a ${shape.name}?',
);
logger.info('You chose the following shape: $shape!');

final shapes = logger.chooseAny<Shape>(
'Or did you want to choose multiple?',
choices: Shape.values,
defaultValues: [shape],
display: (shape) => 'Is it a ${shape.name}?',
);
logger.info('You chose the following shapes: $shapes!');

final favoriteAnimal = logger.prompt(
'What is your favorite animal?',
defaultValue: '🐈',
Expand Down Expand Up @@ -59,19 +69,4 @@ Future<void> main() async {
uri: Uri.parse('https://github.com/felangel/mason'),
);
logger.info('To learn more, visit the $repoLink.');

final shape = logger.chooseOne<Shape>(
'What is your favorite shape?',
choices: Shape.values,
display: (shape) => 'Is it a ${shape.name}?',
);
logger.info('You chose $shape!');

final shapes = logger.chooseAny<Shape>(
'Or did you want to choose multiples?',
choices: Shape.values,
defaultValues: [shape],
display: (shape) => 'Is it a ${shape.name}?',
);
logger.info('You chose the following shapes: $shapes!');
}
2 changes: 1 addition & 1 deletion packages/mason_logger/pubspec.yaml
@@ -1,6 +1,6 @@
name: mason_logger
description: A reusable Dart logger used by the Mason CLI (package:mason_cli).
version: 0.1.4
version: 0.2.0
homepage: https://github.com/felangel/mason
repository: https://github.com/felangel/mason
issue_tracker: https://github.com/felangel/mason/issues
Expand Down
4 changes: 2 additions & 2 deletions packages/mason_logger/test/src/mason_logger_test.dart
Expand Up @@ -905,7 +905,7 @@ void main() {
);
});

test('converts list to a preferred display', () {
test('converts choices to a preferred display', () {
IOOverrides.runZoned(
() {
const message = 'test message';
Expand Down Expand Up @@ -1285,7 +1285,7 @@ void main() {
);
});

test('converts list to a preferred display', () {
test('converts choices to a preferred display', () {
IOOverrides.runZoned(
() {
const message = 'test message';
Expand Down

0 comments on commit 46e8014

Please sign in to comment.