Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(mason_logger): v0.2.0 #542

Merged
merged 2 commits into from Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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