/
main.dart
55 lines (46 loc) · 1.62 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import 'package:mason_logger/mason_logger.dart';
Future<void> main() async {
final logger = Logger(level: Level.verbose)
..info('info')
..alert('alert')
..err('error')
..success('success')
..warn('warning')
..detail('detail')
..info('');
final favoriteColor = logger.chooseOne(
'Pick a color.',
choices: ['red', 'green', 'blue'],
defaultValue: 'blue',
);
logger.info('Got it, $favoriteColor it is!');
final desserts = logger.chooseAny(
'Which desserts do you like?',
choices: ['🍦', '🍪', '🍩'],
);
logger.info('Awesome, $desserts it is!');
final favoriteAnimal = logger.prompt(
'What is your favorite animal?',
defaultValue: '🐈',
);
final likesCats = logger.confirm('Do you like cats?', defaultValue: true);
final progress = logger.progress('Calculating');
await Future<void>.delayed(const Duration(milliseconds: 500));
progress.update('Halfway!');
await Future<void>.delayed(const Duration(milliseconds: 500));
progress.complete('Done!');
logger
..info('Your favorite animal is a $favoriteAnimal!')
..alert(likesCats ? 'You are a cat person!' : 'You are not a cat person.');
final failing = logger.progress('Trying to fail now!');
await Future<void>.delayed(const Duration(seconds: 1));
failing.fail('See I failed!');
final canceling = logger.progress('Trying to cancel now!');
await Future<void>.delayed(const Duration(seconds: 1));
canceling.cancel();
final repoLink = link(
message: 'GitHub Repository',
uri: Uri.parse('https://github.com/felangel/mason'),
);
logger.info('To learn more, visit the $repoLink.');
}