init static method
Implementation
static Future<DpkCommandRunner> init(List<String> arguments) async {
Logger.root.onRecord.listen((record) {
final nameSubString = record.loggerName.isNotEmpty
? ' [${record.loggerName}]'
: '';
// ignore: avoid_print
print('[${record.level.name}]$nameSubString : ${record.message}');
});
final runner = await DpkCommandRunner._create(
executableName: 'dpk',
description: 'An alternative package manager for Dart',
args: arguments,
);
if (runner.config != null) {
container.registerSingleton<ConfigData>(runner.config!);
}
runner
..addCommand(AddCommand())
..addCommand(DowngradeCommand())
..addCommand(GetCommand())
..addCommand(RemoveCommand())
..addCommand(UpgradeCommand())
..addCommand(PatchCommand());
// RunCommand accesses config in its constructor, so only add it when config is available
if (runner.config != null) {
runner.addCommand(RunCommand());
}
return runner;
}