runConfigServiceCommand function
Future<int>
runConfigServiceCommand(
- ConfigCliCommand cmd, {
- required CliIO io,
- required ExecutionEnv env,
- required String? homeDir,
Runs one fa config <verb> command and returns the process exit code.
Exit codes: 0 success; 1 the command failed (invalid config, unknown key, write refused) — the message is printed, nothing thrown, so a scripting agent always gets a clean textual answer.
Implementation
Future<int> runConfigServiceCommand(
ConfigCliCommand cmd, {
required CliIO io,
required ExecutionEnv env,
required String? homeDir,
}) async {
final service = ConfigService(env: env, homeDir: homeDir);
try {
switch (cmd.verb) {
case 'check':
return await _check(service, io);
case 'path':
return await _path(service, io);
case 'get':
return await _get(service, io, cmd.key!);
case 'set':
return await _set(service, io, cmd.key!, cmd.value!, cmd.scope);
}
} on ConfigException catch (error) {
io.writeln('error: ${error.message}');
return 1;
}
// Unreachable: the parser admits exactly the four verbs above.
return 1;
}