run method
Runs this command.
The return value is wrapped in a Future
if necessary and returned by
CommandRunner.runCommand
.
Implementation
@override
void run() async {
await initializeOnvif();
final users = <String>[];
final hasFile = argResults?.options.contains('users-file') ?? false;
final hasUser = argResults?.options.contains('username') ?? false;
if (hasFile) {
final userFile = File(argResults!['users-file']);
if (!userFile.existsSync()) {
throw UsageException(
'${argResults!['users-file']} - file not found', usage);
}
users.addAll((loadYaml(File(argResults!['users-file']).readAsStringSync())
as YamlList)
.map((userJson) => userJson.toString()));
}
if (hasUser) {
users.add(argResults!['username']);
}
try {
await deviceManagement.deleteUsers(users);
} on DioException catch (err) {
throw UsageException('API usage error:', err.usage);
}
}