@@ -28,31 +28,6 @@ class CommandHandler {
28
28
CommandHandler ({required this .parser, required this .execute});
29
29
}
30
30
31
- // Future<bool> makeHttpPostRequest({
32
- // required String url,
33
- // required Map<String, String> body,
34
- // Map<String, String>? headers,
35
- // }) async {
36
- // try {
37
- // final client = HttpClient();
38
- // final request = await client.postUrl(Uri.parse(url));
39
- // request.headers.contentType = ContentType.json;
40
- // request.write(jsonEncode(body));
41
- // final response = await request.close();
42
- // if (response.statusCode >= 200 && response.statusCode < 300) {
43
- // final responseBody = await response.transform(utf8.decoder).join();
44
- // return true;
45
- // } else {
46
- // print('Error Code: ${response.statusCode}');
47
- // print('Error Body: ${await response.transform(utf8.decoder).join()}');
48
- // return false;
49
- // }
50
- // } catch (e) {
51
- // print('[Instabug-CLI] Error while making HTTP POST request: $e');
52
- // exit(1);
53
- // }
54
- // }
55
-
56
31
void main (List <String > args) async {
57
32
final parser = ArgParser ()..addFlag ('help' , abbr: 'h' );
58
33
@@ -61,7 +36,7 @@ void main(List<String> args) async {
61
36
parser.addCommand (entry.key, entry.value.parser);
62
37
}
63
38
64
- print ('--------------------------------' );
39
+ stdout. writeln ('--------------------------------' );
65
40
66
41
try {
67
42
final result = parser.parse (args);
@@ -72,8 +47,8 @@ void main(List<String> args) async {
72
47
if (command['help' ] == true ) {
73
48
final commandHandler = CommandRegistry .commands[command.name];
74
49
if (commandHandler != null ) {
75
- print ('Usage: instabug ${command .name } [options]' );
76
- print (commandHandler.parser.usage);
50
+ stdout. writeln ('Usage: instabug ${command .name } [options]' );
51
+ stdout. writeln (commandHandler.parser.usage);
77
52
}
78
53
return ;
79
54
}
@@ -83,21 +58,21 @@ void main(List<String> args) async {
83
58
if (commandHandler != null ) {
84
59
commandHandler.execute (command);
85
60
} else {
86
- print ('Unknown command: ${command .name }' );
87
- print ('Available commands: ${CommandRegistry .commandNames .join (', ' )}' );
61
+ stderr. writeln ('Unknown command: ${command .name }' );
62
+ stdout. writeln ('Available commands: ${CommandRegistry .commandNames .join (', ' )}' );
88
63
exit (1 );
89
64
}
90
65
} else {
91
- print ('No applicable command found' );
92
- print ('Usage: instabug [options] <command>' );
93
- print ('Available commands: ${CommandRegistry .commandNames .join (', ' )}' );
94
- print ( ' \n For help on a specific command:' );
95
- print (' instabug <command> --help\n ' );
96
- print (parser.usage);
66
+ stderr. writeln ('No applicable command found' );
67
+ stdout. writeln ('Usage: instabug [options] <command>' );
68
+ stdout. writeln ('Available commands: ${CommandRegistry .commandNames .join (', ' )}' );
69
+ stdout. writeln ( 'For help on a specific command:' );
70
+ stdout. writeln (' instabug <command> --help' );
71
+ stdout. writeln (parser.usage);
97
72
}
98
73
} catch (e) {
99
- print ('[Instabug-CLI] Error: $e ' );
100
- print (parser.usage);
74
+ stderr. writeln ('[Instabug-CLI] Error: $e ' );
75
+ stdout. writeln (parser.usage);
101
76
exit (1 );
102
77
}
103
78
}
0 commit comments