Chromium Code Reviews| Index: pkg/analyzer/bin/formatter.dart |
| =================================================================== |
| --- pkg/analyzer/bin/formatter.dart (revision 32027) |
| +++ pkg/analyzer/bin/formatter.dart (working copy) |
| @@ -63,7 +63,7 @@ |
| selection = _parseSelection(options[SELECTION_FLAG]); |
| formatterSettings = |
| new FormatterOptions(codeTransforms: options[TRANSFORM_FLAG], |
| - pageWidth: _toInt(options[MAX_LINE_FLAG])); |
| + pageWidth: _parseLineLength(options[MAX_LINE_FLAG])); |
| } |
| CodeKind _parseKind(kindOption) { |
| @@ -75,6 +75,20 @@ |
| } |
| } |
| +int _parseLineLength(String lengthOption) { |
| + var length = _toInt(lengthOption); |
| + if (length == null) { |
| + if (lengthOption.toUpperCase() == 'INF') { |
|
lukechurch
2014/01/27 20:39:44
I would recommend also supporting INFINITY - to su
pquitslund
2014/01/27 22:23:37
Done.
|
| + length = -1; |
| + } else { |
| + throw new FormatterException('Line length is specified as an Integer or ' |
| + 'the value "Inf".'); |
| + } |
| + } |
| + return length; |
| +} |
| + |
| + |
| Selection _parseSelection(selectionOption) { |
| if (selectionOption != null) { |
| var units = selectionOption.split(','); |
| @@ -159,10 +173,11 @@ |
| parser.addFlag(TRANSFORM_FLAG, abbr: 't', negatable: false, |
| help: 'Perform code transformations.'); |
| parser.addOption(MAX_LINE_FLAG, abbr: 'l', defaultsTo: '80', |
| - help: 'Wrap lines longer than this length.'); |
| + help: 'Wrap lines longer than this length. ' |
| + 'To never wrap, specify "Inf".'); |
| parser.addOption(KIND_FLAG, abbr: 'k', defaultsTo: 'cu', |
| - help: 'Specify source snippet kind ("stmt" or "cu")' |
| - ' --- [PROVISIONAL API].', hide: true); |
| + help: 'Specify source snippet kind ("stmt" or "cu") ' |
| + '--- [PROVISIONAL API].', hide: true); |
| parser.addOption(SELECTION_FLAG, abbr: 's', |
| help: 'Specify selection information as an offset,length pair ' |
| '(e.g., -s "0,4").', hide: true); |