anchor.diff:    Uri out = cwd.resolve('out.js');
     List<String> options = new List<String>();
   
  +  passThrough(String argument) => options.add(argument);
  +
     List<String> arguments = <String>[];
  -  for (String argument in argv) {
  -    if ('--throw-on-error' == argument) {
  -      throwOnError = true;
  -    } else if ('--suppress-warnings' == argument) {
  -      showWarnings = false;
  -    } else if ('--verbose' == argument) {
  -      verbose = true;
  -    } else if (argument.startsWith('--library-root=')) {
  -      String path =
  -          nativeToUriPath(argument.substring(argument.indexOf('=') + 1));
  +  List<OptionHandler> handlers = <OptionHandler>[
  +    new OptionHandler('--throw-on-error', (_) => throwOnError = true),
  +    new OptionHandler('--suppress-warnings', (_) => showWarnings = false),
  +    new OptionHandler('--verbose', (_) => verbose = true),
  +    new OptionHandler('--library-root=.*', (String argument) {
  +      String path = nativeToUriPath(extractParameter(argument));
         if (!path.endsWith("/")) path = "$path/";
         libraryRoot = cwd.resolve(path);
  -    } else if (argument.startsWith('--out=')) {
  -      String path =
  -          nativeToUriPath(argument.substring(argument.indexOf('=') + 1));
  -      out = cwd.resolve(path);
  -    } else if ('--allow-mock-compilation' == argument) {
  -      options.add(argument);
  -    } else if ('--no-colors' == argument) {
  -      colors.enabled = false;
  -    } else if ('--enable-checked-mode' == argument) {
  -      options.add(argument);
  -    } else if (argument.startsWith('-')) {
  -      fail('Unknown option $argument.');
  -    } else {
  +    }),
  +    new OptionHandler('--out=.*', (String argument) {
  +      out = cwd.resolve(nativeToUriPath(extractParameter(argument)));
  +    }),
  +    new OptionHandler('--allow-mock-compilation', passThrough),
  +    new OptionHandler('--no-colors', (_) => colors.enabled = false),
  +    new OptionHandler('--enable-checked-mode|--checked|-c',
  +                      (_) => passThrough('--enable_checked_mode')),
  +    new OptionHandler('--help', (_) => helpAndExit()),
  +    // The following two options must come last.
  +    new OptionHandler('-.*', (String argument) {
  +      fail('Error: unknown option "$argument".');
  +    }),
  +    new OptionHandler('.*', (String argument) {
         arguments.add(nativeToUriPath(argument));
  -    }
  -  }
  +    })
  +  ];
  +
  +  parseCommandLine(handlers, argv);
  +
     if (arguments.isEmpty()) {
  -    fail('No file to compile.');
  +    helpAndFail('Error: no file to compile.');
     }
     if (arguments.length > 1) {
       var extra = arguments.getRange(1, arguments.length - 1);
  -    fail('Extra arguments: $extra.');
  +    helpAndFail('Error: extra arguments: ${Strings.join(extra, " ")}');
     }
   
     Map<String, SourceFile> sourceFiles = <SourceFile>{};
  
positive.code: #import('util/uri_extras.dart');
  
  final String LIBRARY_ROOT = '../../../..';
  
  void compile(List<String> argv) {
    Uri cwd = getCurrentDirectory();
  
negative.code:   // directly. In effect, we don't support truly asynchronous API.
    String code = api.compile(uri, libraryRoot, provider, handler, options).value;
    if (code === null) {
      fail('Error: compilation failed.');
    }
    writeString(out, code);
    int jsBytesWritten = code.length;
  