parseNavigationArgs function

WorkspaceNavigationArgs parseNavigationArgs(
  1. ArgResults results, {
  2. bool bareRoot = false,
})

Parse navigation options from ArgResults.

Call this after parsing with an ArgParser that has had addNavigationOptions called on it.

The bareRoot parameter should come from preprocessRootFlag.

Implementation

WorkspaceNavigationArgs parseNavigationArgs(
  ArgResults results, {
  bool bareRoot = false,
}) {
  String? root = results['root'] as String?;
  if (root == '__BARE_ROOT__') {
    root = null;
    bareRoot = true;
  }

  final recursiveExplicitlySet = results.wasParsed('recursive');

  return WorkspaceNavigationArgs(
    scan: results['scan'] as String?,
    recursive: results['recursive'] as bool? ?? false,
    recursiveExplicitlySet: recursiveExplicitlySet,
    buildOrder: results['build-order'] as bool? ?? false,
    excludeDev: results['exclude-dev'] as bool? ?? false,
    project: results['project'] as String?,
    root: root,
    bareRoot: bareRoot,
    workspaceRecursion: results['workspace-recursion'] as bool? ?? false,
    innerFirstGit: results['inner-first-git'] as bool? ?? false,
    outerFirstGit: results['outer-first-git'] as bool? ?? false,
    topRepo: results['top-repo'] as bool? ?? false,
    exclude: results['exclude'] as List<String>? ?? [],
    excludeProjects: results['exclude-projects'] as List<String>? ?? [],
    recursionExclude: results['recursion-exclude'] as List<String>? ?? [],
    modules: _parseCommaSeparated(results['modules'] as String?),
    noSkip: results['no-skip'] as bool? ?? false,
    modes: _parseModesOption(results['modes'] as String?),
  );
}