main function
Main entry point for commands.
This function is intended to be used from the faircli
command line tool.
Implementation
Future<void> main(List<String> args) async {
final bool veryVerbose = args.contains('-vv');
final bool verbose =
args.contains('-v') || args.contains('--verbose') || veryVerbose;
final int powershellHelpIndex = args.indexOf('-?');
if (powershellHelpIndex != -1) {
args[powershellHelpIndex] = '-h';
}
final bool doctor = (args.isNotEmpty && args.first == 'doctor') ||
(args.length == 2 && verbose && args.last == 'doctor');
final bool help = args.contains('-h') ||
args.contains('--help') ||
(args.isNotEmpty && args.first == 'help') ||
(args.length == 1 && verbose);
final bool muteCommandLogging = (help || doctor) && !veryVerbose;
final bool verboseHelp = help && verbose;
// set faircli path
var midPath = platform.isWindows ? '\\bin\\' : '/bin/';
var scriptRoot = platform.script.toFilePath();
if (scriptRoot.contains(midPath)) {
globals.faircliRoot =
scriptRoot.substring(0, scriptRoot.lastIndexOf(midPath));
} else {
print('init faircli root path error ...');
}
await runner.run(
args,
() => generateCommands(
verboseHelp: verboseHelp,
verbose: verbose,
),
verbose: verbose,
muteCommandLogging: muteCommandLogging,
verboseHelp: verboseHelp,
overrides: {}, flutterVersion: '',
);
}