flutter/dev/tools/localizations_utils.dart
Yegor 41bd66f210
remove locale "sd" (not supported by ICU/CLDR); unify localizations script options (#12803)
* remove locale "sd" (not supported by ICU/CLDR); unify localizations scripts CLI

* address comments
2017-10-31 20:23:58 -07:00

46 lines
1.1 KiB
Dart

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:args/args.dart' as argslib;
import 'package:meta/meta.dart';
void fatal(String message) {
stderr.writeln(message);
exit(1);
}
void checkCwdIsRepoRoot(String commandName) {
final bool isRepoRoot = new Directory('.git').existsSync();
if (!isRepoRoot) {
fatal(
'$commandName must be run from the root of the Flutter repository. The '
'current working directory is: ${Directory.current.path}'
);
}
}
GeneratorOptions parseArgs(List<String> rawArgs) {
final argslib.ArgParser argParser = new argslib.ArgParser()
..addFlag(
'overwrite',
abbr: 'w',
defaultsTo: false,
);
final argslib.ArgResults args = argParser.parse(rawArgs);
final bool writeToFile = args['overwrite'];
return new GeneratorOptions(writeToFile: writeToFile);
}
class GeneratorOptions {
GeneratorOptions({
@required this.writeToFile,
});
final bool writeToFile;
}