run method

  1. @override
void run()
override

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 needsSourceToken = (argResults?['scope-include-sources-type'] ??
          argResults?['scope-include-sources-token']) !=
      null;

  final sourceToken = needsSourceToken
      ? [
          SourceToken(
              type: argResults?['scope-include-sources-type'],
              token: argResults?['scope-include-sources-token'])
        ]
      : null;

  final needsSearchScope = (sourceToken ??
          argResults?['scope-include-recordings'] ??
          argResults?['scope-recording-information-filter']) !=
      null;

  final searchScope = needsSearchScope
      ? SearchScope(
          includedSources: sourceToken,
          includedRecordings:
              argResults?['scope-include-recordings'].toString().split(','),
          recordingInformationFilter:
              argResults?['scope-recording-information-filter'],
        )
      : null;

  try {
    final searchToken = await search.findRecordings(
        searchScope: searchScope,
        maxMatches: argResults?['max-matches'],
        keepAliveTime: argResults!['keep-alive-time']);

    print(searchToken);
  } on DioException catch (err) {
    throw UsageException('API usage error:', err.usage);
  }
}