| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 usage_test; | 5 library usage_test; |
| 6 | 6 |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'package:args/args.dart'; | 8 import 'package:args/args.dart'; |
| 9 | 9 |
| 10 void main() { | 10 void main() { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 var parser = new ArgParser(); | 115 var parser = new ArgParser(); |
| 116 parser.addOption('any', help: 'Can be anything', defaultsTo: 'whatevs'); | 116 parser.addOption('any', help: 'Can be anything', defaultsTo: 'whatevs'); |
| 117 | 117 |
| 118 validateUsage(parser, | 118 validateUsage(parser, |
| 119 ''' | 119 ''' |
| 120 --any Can be anything | 120 --any Can be anything |
| 121 (defaults to "whatevs") | 121 (defaults to "whatevs") |
| 122 '''); | 122 '''); |
| 123 }); | 123 }); |
| 124 | 124 |
| 125 test('the value help is shown', () { |
| 126 var parser = new ArgParser(); |
| 127 parser.addOption('out', abbr: 'o', help: 'Where to write file', |
| 128 valueHelp: 'path'); |
| 129 |
| 130 validateUsage(parser, |
| 131 ''' |
| 132 -o, --out=<path> Where to write file |
| 133 '''); |
| 134 }); |
| 135 |
| 125 test('the allowed list is shown', () { | 136 test('the allowed list is shown', () { |
| 126 var parser = new ArgParser(); | 137 var parser = new ArgParser(); |
| 127 parser.addOption('suit', help: 'Like in cards', | 138 parser.addOption('suit', help: 'Like in cards', |
| 128 allowed: ['spades', 'clubs', 'hearts', 'diamonds']); | 139 allowed: ['spades', 'clubs', 'hearts', 'diamonds']); |
| 129 | 140 |
| 130 validateUsage(parser, | 141 validateUsage(parser, |
| 131 ''' | 142 ''' |
| 132 --suit Like in cards | 143 --suit Like in cards |
| 133 [spades, clubs, hearts, diamonds] | 144 [spades, clubs, hearts, diamonds] |
| 134 '''); | 145 '''); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 throw new ArgumentError( | 255 throw new ArgumentError( |
| 245 'Line "$line" does not have enough indentation.'); | 256 'Line "$line" does not have enough indentation.'); |
| 246 } | 257 } |
| 247 | 258 |
| 248 lines[i] = line.substring(indent); | 259 lines[i] = line.substring(indent); |
| 249 } | 260 } |
| 250 } | 261 } |
| 251 | 262 |
| 252 return lines.join('\n'); | 263 return lines.join('\n'); |
| 253 } | 264 } |
| OLD | NEW |