Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Unified Diff: pkg/status_file/bin/format.dart

Issue 2988383002: A minimal status file formatter and canonicalizer. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/status_file/lib/expectation.dart » ('j') | pkg/status_file/lib/status_file.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/status_file/bin/format.dart
diff --git a/pkg/status_file/bin/format.dart b/pkg/status_file/bin/format.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f78916cd9a9f892192831201c74776e75663bd61
--- /dev/null
+++ b/pkg/status_file/bin/format.dart
@@ -0,0 +1,37 @@
+// Copyright (c) 2017, 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.
+
+/// Reformats the status file(s) at the given path.
+import 'dart:io';
+
+import 'package:status_file/status_file.dart';
+
+void main(List<String> arguments) {
+ if (arguments.length != 1) {
+ print("Usage: dart status_file/bin/format.dart <path>");
+ exit(1);
+ }
+
+ var path = arguments[0];
+
+ if (new File(path).existsSync()) {
+ formatFile(path);
+ } else if (new Directory(path).existsSync()) {
+ for (var entry in new Directory(path).listSync(recursive: true)) {
+ if (!entry.path.endsWith(".status")) continue;
+
+ formatFile(entry.path);
+ }
+ }
+}
+
+void formatFile(String path) {
+ try {
+ var statusFile = new StatusFile.read(path);
+ new File(path).writeAsStringSync(statusFile.serialize());
+ print("Formatted $path");
+ } on SyntaxError catch (error) {
+ stderr.writeln("Could not parse $path:\n$error");
+ }
+}
« no previous file with comments | « no previous file | pkg/status_file/lib/expectation.dart » ('j') | pkg/status_file/lib/status_file.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698