OLD | NEW |
1 import 'dart:io'; | 1 import 'dart:io'; |
2 | 2 |
3 import 'package:args/args.dart'; | 3 import 'package:args/args.dart'; |
4 import 'package:dart_style/src/io.dart'; | 4 import 'package:dart_style/src/io.dart'; |
5 | 5 |
6 void main(List<String> args) { | 6 void main(List<String> args) { |
7 var parser = new ArgParser(allowTrailingOptions: true); | 7 var parser = new ArgParser(allowTrailingOptions: true); |
8 | 8 |
9 parser.addFlag("help", abbr: "h", negatable: false, | 9 parser.addFlag("help", abbr: "h", negatable: false, |
10 help: "Shows usage information."); | 10 help: "Shows usage information."); |
11 parser.addOption("line-length", abbr: "l", | 11 parser.addOption("line-length", abbr: "l", |
12 help: "Wrap lines longer than this.", | 12 help: "Wrap lines longer than this.", |
13 defaultsTo: "80"); | 13 defaultsTo: "80"); |
14 parser.addFlag("dry-run", abbr: "n", negatable: false, | 14 parser.addFlag("dry-run", abbr: "n", negatable: false, |
15 help: "Show which files would be modified but make no changes."); | 15 help: "Show which files would be modified but make no changes."); |
16 parser.addFlag("overwrite", abbr: "w", negatable: false, | 16 parser.addFlag("overwrite", abbr: "w", negatable: false, |
17 help: "Overwrite input files with formatted output.\n" | 17 help: "Overwrite input files with formatted output.\n" |
18 "If unset, prints results to standard output."); | 18 "If unset, prints results to standard output."); |
19 parser.addFlag("follow-links", negatable: false, | 19 parser.addFlag("follow-links", negatable: false, |
20 help: "Follow links to files and directories.\n" | 20 help: "Follow links to files and directories.\n" |
21 "If unset, links will be ignored."); | 21 "If unset, links will be ignored."); |
| 22 parser.addFlag("transform", abbr: "t", negatable: false, |
| 23 help: "Unused flag for compability with the old formatter."); |
22 | 24 |
23 var options; | 25 var options; |
24 try { | 26 try { |
25 options = parser.parse(args); | 27 options = parser.parse(args); |
26 } on FormatException catch (err) { | 28 } on FormatException catch (err) { |
27 printUsage(parser, err.message); | 29 printUsage(parser, err.message); |
28 exitCode = 64; | 30 exitCode = 64; |
29 return; | 31 return; |
30 } | 32 } |
31 | 33 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 var output = stdout; | 96 var output = stdout; |
95 | 97 |
96 var message = "Reformats whitespace in Dart source files."; | 98 var message = "Reformats whitespace in Dart source files."; |
97 if (error != null) { | 99 if (error != null) { |
98 message = error; | 100 message = error; |
99 output = stdout; | 101 output = stdout; |
100 } | 102 } |
101 | 103 |
102 output.write("""$message | 104 output.write("""$message |
103 | 105 |
104 Usage: dartformat [-l <line length>] <files or directories...> | 106 Usage: dartformat [-w] <files or directories...> |
105 | 107 |
106 ${parser.usage} | 108 ${parser.usage} |
107 """); | 109 """); |
108 } | 110 } |
OLD | NEW |