run method
Runs the Loki CLI tool with the provided arguments.
It initializes a CommandRunner and adds various commands for different functionalities, such as fetching, cleaning, listing, running, validating, viewing version, and managing applications.
Exits with code 1 on PathNotFoundException if loki.yaml is not found.
Exits with code 1 on LokiError
for other Loki-specific errors.
Exits with code 1 on YamlException if there is an issue parsing Yaml.
Exits with code 1 on ArgParserException if there is an issue parsing command-line arguments.
Exits with code 1 on UsageException if there is an issue with command usage.
Implementation
Future<void> run(List<String> arguments) async {
_drawLogo();
try {
final runner = CommandRunner<void>(_executableName, _description)
..addCommand(FetchCommand())
..addCommand(CleanCommand())
..addCommand(ListCommand())
..addCommand(RunCommand())
..addCommand(ValidateCommand())
..addCommand(VersionCommand())
..addCommand(AppCommand())
;
await runner.run(arguments);
} on PathNotFoundException catch (e, _) {
console.writeln(LokiError('Could not find loki.yaml').toString());
exit(1);
} on LokiError catch (e, _) {
console.writeln(e.toString());
exit(1);
} on YamlException catch (e) {
console.writeln(LokiError('Could not parse Yaml.${chalk.normal(
'\nPlease check the file and try again')}').toString());
exit(1);
} on ArgParserException catch(e){
console.writeln(LokiError(e.message).toString());
exit(1);
} on UsageException catch(e){
console.writeln(e.toString());
exit(1);
}
}