function parseOptions


CommandLineOptions parseOptions([List<String> args])

Parse command-line arguments and return a CommandLineOptions object. The following flags are parsed by this method.

Currently not all the flags are used by lint or deploy above, but they are available so they can be used from your build.dart. For instance, see the top-level library documentation for an example that uses the force-deploy option to conditionally call deploy.

If this documentation becomes out of date, the best way to discover which flags are supported is to invoke this function from your build.dart, and run it with the --help command-line flag.

Source

CommandLineOptions parseOptions([List<String> args]) {
  if (args == null) {
    print('warning: the list of arguments from main(List<String> args) now '
        'needs to be passed explicitly to parseOptions.');
    args = [];
  }
  var parser = new ArgParser()
    ..addOption('changed',
        help: 'The file has changed since the last build.', allowMultiple: true)
    ..addOption('removed',
        help: 'The file was removed since the last build.', allowMultiple: true)
    ..addFlag('clean',
        negatable: false, help: 'Remove any build artifacts (if any).')
    ..addFlag('full', negatable: false, help: 'perform a full build')
    ..addFlag('machine',
        negatable: false,
        help: 'Produce warnings in a machine parseable format.')
    ..addFlag('deploy', negatable: false, help: 'Whether to force deploying.')
    ..addOption('out',
        abbr: 'o', help: 'Directory to generate files into.', defaultsTo: 'out')
    ..addFlag('js',
        help: 'deploy replaces *.dart scripts with *.dart.js. This flag \n'
        'leaves "packages/browser/dart.js" to do the replacement at runtime.',
        defaultsTo: true)
    ..addFlag('csp', help: 'extracts inlined JavaScript code to comply with \n'
        'Content Security Policy restrictions.')
    ..addFlag('debug',
        help: 'run in debug mode. For example, use the debug polyfill \n'
        'web_components/webcomponents.js instead of the minified one.\n',
        defaultsTo: false)
    ..addFlag('help',
        abbr: 'h', negatable: false, help: 'Displays this help and exit.');

  showUsage() {
    print('Usage: dart build.dart [options]');
    print('\nThese are valid options expected by build.dart:');
    print(parser.getUsage());
  }

  var res;
  try {
    res = parser.parse(args);
  } on FormatException catch (e) {
    print(e.message);
    showUsage();
    exit(1);
  }
  if (res['help']) {
    print('A build script that invokes the polymer linter and deploy tools.');
    showUsage();
    exit(0);
  }
  return new CommandLineOptions(res['changed'], res['removed'], res['clean'],
      res['full'], res['machine'], res['deploy'], res['out'], res['js'],
      res['csp'], !res['debug']);
}