SharedOptions.create constructor

SharedOptions.create(
  1. ArgResults? argResults
)

Implementation

factory SharedOptions.create(ArgResults? argResults) {
  final SharedOptions defaultOptions = SharedOptions.defaults();

  final YamlMap? yaml = getConfig(configPathOption.defaultsTo);
  final SharedOptions? yamlOptions = formatToolOptions(yaml);
  final List<String>? flutterAssets = formatAssetList(yaml);

  final SharedOptions argOptions = SharedOptions.formARG(argResults);

  final SharedOptions? toolOptions = formatToolOptions(
    getConfig(
      argOptions.configPath.isNotEmpty
        ? argOptions.configPath
        : (
          yamlOptions?.configPath.isNotEmpty ?? false
            ? yamlOptions!.configPath
            : defaultOptions.configPath
        )
    )
  );

  return SharedOptions(
    libPaths: argOptions.libPaths.isNotEmpty
      ? argOptions.libPaths
      : toolOptions?.libPaths.isNotEmpty ?? false
        ? toolOptions!.libPaths
        : yamlOptions?.libPaths.isNotEmpty ?? false
          ? yamlOptions!.libPaths
          : defaultOptions.libPaths,
    assetPaths: argOptions.assetPaths.isNotEmpty
      ? argOptions.assetPaths
      : toolOptions?.assetPaths.isNotEmpty ?? false
        ? toolOptions!.assetPaths
        : yamlOptions?.assetPaths.isNotEmpty ?? false
          ? yamlOptions!.assetPaths
          : flutterAssets?.isNotEmpty ?? false
            ? flutterAssets!
            : defaultOptions.assetPaths,
    dustbinPath: argOptions.dustbinPath.isNotEmpty
      ? argOptions.dustbinPath
      : toolOptions?.dustbinPath.isNotEmpty ?? false
        ? toolOptions!.dustbinPath
        : yamlOptions?.dustbinPath.isNotEmpty ?? false
          ? yamlOptions!.dustbinPath
          : defaultOptions.dustbinPath,
    listPath: argOptions.listPath.isNotEmpty
      ? argOptions.listPath
      : toolOptions?.listPath.isNotEmpty ?? false
        ? toolOptions!.listPath
        : yamlOptions?.listPath.isNotEmpty ?? false
          ? yamlOptions!.listPath
          : defaultOptions.listPath,
    configPath: argOptions.configPath.isNotEmpty
      ? argOptions.configPath
      : toolOptions?.configPath.isNotEmpty ?? false
        ? toolOptions!.configPath
        : yamlOptions?.configPath.isNotEmpty ?? false
          ? yamlOptions!.configPath
          : defaultOptions.configPath,
    nameReplaces: argOptions.nameReplaces.isNotEmpty
      ? argOptions.nameReplaces
      : toolOptions?.nameReplaces.isNotEmpty ?? false
        ? toolOptions!.nameReplaces
        : yamlOptions?.nameReplaces.isNotEmpty ?? false
          ? yamlOptions!.nameReplaces
          : defaultOptions.nameReplaces,
    excludePaths: argOptions.excludePaths.isNotEmpty
      ? argOptions.excludePaths
      : toolOptions?.excludePaths.isNotEmpty ?? false
        ? toolOptions!.excludePaths
        : yamlOptions?.excludePaths.isNotEmpty ?? false
          ? yamlOptions!.excludePaths
          : defaultOptions.excludePaths,
    formatType: argOptions.formatType != null
      ? argOptions.formatType!
      : toolOptions?.formatType != null
        ? toolOptions!.formatType
        : yamlOptions?.formatType != null
          ? yamlOptions!.formatType
          : defaultOptions.formatType!,
  );
}