-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflutter_symbols.dart
More file actions
113 lines (105 loc) · 2.31 KB
/
flutter_symbols.dart
File metadata and controls
113 lines (105 loc) · 2.31 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import 'dart:io';
import 'package:args/args.dart';
import 'package:raygun_cli/config_props.dart';
import 'package:raygun_cli/symbols/flutter_symbols_api.dart';
const kSymbolsCommand = 'symbols';
void parseSymbolsCommand(ArgResults command, bool verbose) {
if (command.wasParsed('help')) {
print(
'Usage: raygun-cli $kSymbolsCommand (upload|list|delete) <arguments>');
print(buildParserSymbols().usage);
exit(0);
}
_run(
command: command,
appId: ConfigProp.appId.load(command),
token: ConfigProp.token.load(command),
).then((result) {
if (result) {
exit(0);
} else {
exit(2);
}
}).catchError((e) {
print('Error: $e');
exit(2);
});
}
Future<bool> _run({
required ArgResults command,
required appId,
required token,
}) async {
if (command.command?.name == 'upload') {
if (!command.wasParsed('path') || !command.wasParsed('version')) {
print('Missing mandatory arguments');
print(buildParserSymbols().usage);
return false;
}
final path = command['path'];
final version = command['version'];
return uploadSymbols(
appId: appId,
token: token,
path: path,
version: version,
);
}
if (command.command?.name == 'list') {
return listSymbols(
appId: appId,
token: token,
);
}
if (command.command?.name == 'delete') {
if (!command.wasParsed('id')) {
print('Missing mandatory arguments');
print(buildParserSymbols().usage);
return false;
}
return deleteSymbols(
appId: appId,
token: token,
id: command['id'],
);
}
return false;
}
ArgParser buildParserSymbols() {
return ArgParser()
..addFlag(
'help',
abbr: 'h',
negatable: false,
help: 'Print $kSymbolsCommand usage information.',
)
..addOption(
'app-id',
help: 'Raygun application ID',
)
..addOption(
'token',
help: 'Raygun access token',
)
..addOption(
'path',
help: 'Path to symbols file, used in upload',
)
..addOption(
'version',
help: 'App version, used in upload',
)
..addOption(
'id',
help: 'Symbol ID, used in delete',
)
..addCommand(
'upload',
)
..addCommand(
'list',
)
..addCommand(
'delete',
);
}