OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library args.src.usage; | 5 library args.src.usage; |
6 | 6 |
7 import 'dart:math'; | 7 import 'dart:math'; |
8 | 8 |
9 import '../args.dart'; | 9 import '../args.dart'; |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 | 121 |
122 String getAllowedTitle(String allowed) { | 122 String getAllowedTitle(String allowed) { |
123 return ' [$allowed]'; | 123 return ' [$allowed]'; |
124 } | 124 } |
125 | 125 |
126 void calculateColumnWidths() { | 126 void calculateColumnWidths() { |
127 int abbr = 0; | 127 int abbr = 0; |
128 int title = 0; | 128 int title = 0; |
129 args.options.forEach((name, option) { | 129 args.options.forEach((name, option) { |
| 130 if (option.hide) return; |
| 131 |
130 // Make room in the first column if there are abbreviations. | 132 // Make room in the first column if there are abbreviations. |
131 abbr = max(abbr, getAbbreviation(option).length); | 133 abbr = max(abbr, getAbbreviation(option).length); |
132 | 134 |
133 // Make room for the option. | 135 // Make room for the option. |
134 title = max(title, getLongOption(option).length); | 136 title = max(title, getLongOption(option).length); |
135 | 137 |
136 // Make room for the allowed help. | 138 // Make room for the allowed help. |
137 if (option.allowedHelp != null) { | 139 if (option.allowedHelp != null) { |
138 for (var allowed in option.allowedHelp.keys) { | 140 for (var allowed in option.allowedHelp.keys) { |
139 title = max(title, getAllowedTitle(allowed).length); | 141 title = max(title, getAllowedTitle(allowed).length); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 String padRight(String source, int length) { | 233 String padRight(String source, int length) { |
232 final result = new StringBuffer(); | 234 final result = new StringBuffer(); |
233 result.write(source); | 235 result.write(source); |
234 | 236 |
235 while (result.length < length) { | 237 while (result.length < length) { |
236 result.write(' '); | 238 result.write(' '); |
237 } | 239 } |
238 | 240 |
239 return result.toString(); | 241 return result.toString(); |
240 } | 242 } |
OLD | NEW |