doRun method
Implementation
@override
Future<int> doRun() async {
final ar = argResults!;
final isReset = ar.getBool(_argReset);
final args = ar.rest;
final expectedArgsCount = isReset ? 1 : 2;
if (args.length != expectedArgsCount) {
if (args.length > expectedArgsCount) {
printError(isReset
? 'You should pass only setting name with reset flag'
: 'You should pass only setting name and value');
} else {
printError(isReset
? 'You should pass setting name'
: 'You should pass setting name and value');
}
printInfo('See description below:');
printInfo('');
printUsage();
return error(1);
}
final alexSettings = settings;
final name = args[0];
final processor = _supportedSettings[name];
if (processor == null) {
return error(
1,
message: 'Setting "$name" is not supported.\n'
'List of supported settings:\n${_getSupportedSettings(' - ')}',
);
}
final value = isReset ? '' : args[1];
printVerbose('Set <$name> to "$value"');
await processor.item2.call(alexSettings, value);
return success(message: 'Saved ⚙️');
}