run method

  1. @override
String run(
  1. ParsedInputs inputs,
  2. List<String> args
)
override

Implementation

@override
String run(ParsedInputs inputs, List<String> args) {
  final name = inputs.valueOf(commandName);
  final targetPath = inputs.valueOf(sourcePath);
  final shouldAppend = inputs.valueOf(append);

  if (targetPath != null && !shouldAppend) {
    throw MambaException('The file argument requires --append.');
  }
  if (targetPath == null && shouldAppend) {
    throw MambaException('--append requires a file argument.');
  }

  final sourceFile = targetPath == null
      ? File(
          '${_parentDirectory.path}${Platform.pathSeparator}lib'
          '${Platform.pathSeparator}$name.dart',
        )
      : File(targetPath);

  final testFile = _createTestSuiteFile(
    name,
    sourceFile,
    appendToSuite: shouldAppend,
  );
  return shouldAppend
      ? 'Added test suite to ${testFile.path}.'
      : 'Created test suite in ${testFile.path}.';
}