-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
47 lines (40 loc) · 1.31 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
import 'package:dart_cli_with_fpdart/cli_error.dart';
import 'package:dart_cli_with_fpdart/import_match.dart';
import 'package:dart_cli_with_fpdart/main_layer.dart';
import 'package:fpdart/fpdart.dart';
typedef FileUsage = ({
Iterable<ImportMatch> unused,
Iterable<ImportMatch> used,
ImportMatch entry,
});
ReaderTaskEither<MainLayer, CliError, FileUsage> program(
List<String> arguments) =>
ReaderTaskEither<MainLayer, CliError, FileUsage>.Do(
(_) async {
final layer = await _(ReaderTaskEither.ask());
final cliOptions = await _(
ReaderTaskEither.fromIOEither(
layer.argumentsParser.parse(arguments),
),
);
final packageName = await _(
ReaderTaskEither.fromTaskEither(
layer.configReader.packageName(cliOptions),
),
);
final entry = ImportMatch(cliOptions.entry);
final readFile = await _(
ReaderTaskEither.fromTaskEither(
layer.fileReader.listFilesLibDir(packageName, entry),
),
);
final fileUsage = readFile.fileList.partition(
(projectFile) => readFile.importSet.contains(projectFile),
);
return (
unused: fileUsage.$1,
used: fileUsage.$2,
entry: entry,
);
},
);