blob: f600915619bbee9259436d43c25e30fda654bc1f [file] [log] [blame]
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// This is an example of converting the args in test.dart to use this API.
/// It shows what it looks like to build an [ArgParser] and then, when the code
/// is run, demonstrates what the generated usage text looks like.
library example;
import 'dart:io';
import 'package:args/args.dart';
void main() {
var parser = ArgParser();
parser.addSeparator('===== Platform');
abbr: 'c',
defaultsTo: 'none',
help: 'Specify any compilation step (if needed).',
allowed: [
allowedHelp: {
'none': 'Do not compile the Dart code (run native Dart code on the'
' VM).\n(only valid with the following runtimes: vm, drt)',
'dart2js': 'Compile dart code to JavaScript by running dart2js.\n'
'(only valid with the following runtimes: d8, drt, chrome\n'
'safari, ie, firefox, opera, none (compile only))',
'dartc': 'Perform static analysis on Dart code by running dartc.\n'
'(only valid with the following runtimes: none)',
abbr: 'r',
defaultsTo: 'vm',
help: 'Where the tests should be run.',
allowed: [
allowedHelp: {
'vm': 'Run Dart code on the standalone dart vm.',
'd8': 'Run JavaScript from the command line using v8.',
// TODO(antonm): rename flag.
'drt': 'Run Dart or JavaScript in the headless version of Chrome,\n'
'content shell.',
'dartium': 'Run Dart or JavaScript in Dartium.',
'ff': 'Run JavaScript in Firefox',
'chrome': 'Run JavaScript in Chrome',
'safari': 'Run JavaScript in Safari',
'ie': 'Run JavaScript in Internet Explorer',
'opera': 'Run JavaScript in Opera',
'none': 'No runtime, compile only (for example, used for dartc static\n'
'analysis tests).',
abbr: 'a',
defaultsTo: 'ia32',
help: 'The architecture to run tests for',
allowed: ['all', 'ia32', 'x64', 'simarm']);
abbr: 's',
defaultsTo: Platform.operatingSystem,
help: 'The operating system to run tests on',
allowed: ['linux', 'macos', 'windows']);
parser.addSeparator('===== Runtime');
abbr: 'm',
defaultsTo: 'debug',
help: 'Mode in which to run the tests',
allowed: ['all', 'debug', 'release']);
defaultsTo: false, help: 'Run tests in checked mode');
defaultsTo: false, help: 'Run compiler in checked mode');
parser.addOption('timeout', abbr: 't', help: 'Timeout in seconds');
abbr: 'j',
defaultsTo: Platform.numberOfProcessors.toString(),
help: 'The number of parallel tasks to run');
defaultsTo: '1',
help: 'The number of instances that the tests will be sharded over');
defaultsTo: '1',
help: 'The index of this instance when running in sharded mode');
defaultsTo: false, help: 'Run tests through valgrind');
parser.addSeparator('===== Output');
abbr: 'p',
defaultsTo: 'compact',
help: 'Progress indication mode',
allowed: [
defaultsTo: false,
help: 'Print a summary report of the number of tests, by expectation');
abbr: 'v', defaultsTo: false, help: 'Verbose output');
defaultsTo: false, help: 'List tests only, do not run them');
help: 'Print timing information after running tests', defaultsTo: false);
abbr: 'b', help: 'Run browser tests in batch mode', defaultsTo: true);
parser.addSeparator('===== Miscellaneous');
defaultsTo: false,
help: 'Keep the generated files in the temporary directory');
parser.addOption('special-command', help: """
Special command support. Wraps the command line in
a special command. The special command should contain
an '@' character which will be replaced by the normal
For example if the normal command that will be executed
is 'dart file.dart' and you specify special command
'python -u @ suffix' the final command will be
'python -u dart file.dart suffix'""");
parser.addOption('dart', help: 'Path to dart executable');
parser.addOption('drt', help: 'Path to content shell executable');
parser.addOption('dartium', help: 'Path to Dartium Chrome executable');