I want to have a Windows executable created with Flutter to be able to accept command arguments and print the result inside my CMD when I execute it like this :
commandtest.exe --type=csv
I wrote this code :
import 'dart:io';
import 'package:args/args.dart';
void main(List<String> args) {
var parser = ArgParser()..addOption("type", abbr: 't', defaultsTo: 'default');
try {
final ArgResults argResults = parser.parse(args);
final String type = argResults['type'] as String;
stdout.writeln('Type: $type'); // print() doesn't work either
exit(0);
} on Exception catch (e) {
stderr.writeln("error on parsing args : $e");
exit(1);
}
}
Here's my expected behavior, in my CMD :
path/to/executable> mycommand.exe --type=csv
Type: csv
path/to/executable>
But for now, nothing works and my CMD is empty when i run my command :
path/to/executable> mycommand.exe --type=csv
path/to/executable>
However, I know it works because when I try my command like this :
mycommand.exe --type=csv > output.txt
the output.txt file is created and my result is correctly pushed inside.
I don't see where's the problem. Help please ?