run method
Runs this command.
The return value is wrapped in a Future
if necessary and returned by
CommandRunner.runCommand
.
Implementation
@override
Future<void> run() async {
final rest = argResults!.rest;
if (rest.length > 1) {
printErrorAndExit('--- Too many arguments specified ---');
}
final apiKey = Platform.environment['KENALL_API_KEY'];
if (apiKey == null) {
printErrorAndExit('--- KENALL_API_KEY is not found ---');
}
final houjinbangou = argResults!['houjinbangou'] ?? '';
if (houjinbangou.isEmpty) {
printErrorAndExit('--- arguments houjinbangou is not found ---');
}
final config = Config(apiKey: apiKey!);
final kenallClient = KenallClient(config, http.Client());
try {
final response = await kenallClient.getHoujinbangou(
GetHoujinBangouRequest(houjinbangou: houjinbangou),
);
printInfo('version: ${response.version}');
printInfo('houjinbangou: ${response.houjinbangou}');
exit(0);
} catch (error) {
printErrorAndExit('--- $error ---');
}
}