| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 String getAbbreviation(Option option) { | 102 String getAbbreviation(Option option) { |
| 103 if (option.abbreviation != null) { | 103 if (option.abbreviation != null) { |
| 104 return '-${option.abbreviation}, '; | 104 return '-${option.abbreviation}, '; |
| 105 } else { | 105 } else { |
| 106 return ''; | 106 return ''; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 String getLongOption(Option option) { | 110 String getLongOption(Option option) { |
| 111 var result; |
| 111 if (option.negatable) { | 112 if (option.negatable) { |
| 112 return '--[no-]${option.name}'; | 113 result = '--[no-]${option.name}'; |
| 113 } else { | 114 } else { |
| 114 return '--${option.name}'; | 115 result = '--${option.name}'; |
| 115 } | 116 } |
| 117 |
| 118 if (option.valueHelp != null) result += "=<${option.valueHelp}>"; |
| 119 |
| 120 return result; |
| 116 } | 121 } |
| 117 | 122 |
| 118 String getAllowedTitle(String allowed) { | 123 String getAllowedTitle(String allowed) { |
| 119 return ' [$allowed]'; | 124 return ' [$allowed]'; |
| 120 } | 125 } |
| 121 | 126 |
| 122 void calculateColumnWidths() { | 127 void calculateColumnWidths() { |
| 123 int abbr = 0; | 128 int abbr = 0; |
| 124 int title = 0; | 129 int title = 0; |
| 125 args.options.forEach((name, option) { | 130 args.options.forEach((name, option) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 String padRight(String source, int length) { | 234 String padRight(String source, int length) { |
| 230 final result = new StringBuffer(); | 235 final result = new StringBuffer(); |
| 231 result.write(source); | 236 result.write(source); |
| 232 | 237 |
| 233 while (result.length < length) { | 238 while (result.length < length) { |
| 234 result.write(' '); | 239 result.write(' '); |
| 235 } | 240 } |
| 236 | 241 |
| 237 return result.toString(); | 242 return result.toString(); |
| 238 } | 243 } |
| OLD | NEW |