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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /// Reformats the status file(s) at the given path.
6 import 'dart:io';
7
8 import 'package:status_file/status_file.dart';
9
10 void main(List<String> arguments) {
11 if (arguments.length != 1) {
12 print("Usage: dart status_file/bin/format.dart <path>");
13 exit(1);
14 }
15
16 var path = arguments[0];
17
18 if (new File(path).existsSync()) {
19 formatFile(path);
20 } else if (new Directory(path).existsSync()) {
21 for (var entry in new Directory(path).listSync(recursive: true)) {
22 if (!entry.path.endsWith(".status")) continue;
23
24 formatFile(entry.path);
25 }
26 }
27 }
28
29 void formatFile(String path) {
30 try {
31 var statusFile = new StatusFile.read(path);
32 new File(path).writeAsStringSync(statusFile.serialize());
33 print("Formatted $path");
34 } on SyntaxError catch (error) {
35 stderr.writeln("Could not parse $path:\n$error");
36 }
37 }
OLDNEW
« 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