| 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 main() { | 10 main() { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 validateUsage(parser, | 160 validateUsage(parser, |
| 161 ''' | 161 ''' |
| 162 --suit Like in cards | 162 --suit Like in cards |
| 163 | 163 |
| 164 [clubs] Weapons of war | 164 [clubs] Weapons of war |
| 165 [diamonds] Money for this art | 165 [diamonds] Money for this art |
| 166 [hearts] The shape of my heart | 166 [hearts] The shape of my heart |
| 167 [spades] Swords of a soldier | 167 [spades] Swords of a soldier |
| 168 '''); | 168 '''); |
| 169 }); | 169 }); |
| 170 |
| 171 test("hidden flags don't appear in the help", () { |
| 172 var parser = new ArgParser(); |
| 173 parser.addOption('first', help: 'The first option'); |
| 174 parser.addOption('second', isHidden: true); |
| 175 parser.addOption('third', help: 'The third option'); |
| 176 |
| 177 |
| 178 validateUsage(parser, |
| 179 ''' |
| 180 --first The first option |
| 181 --third The third option |
| 182 '''); |
| 183 }); |
| 170 }); | 184 }); |
| 171 } | 185 } |
| 172 | 186 |
| 173 throwsIllegalArg(function) { | 187 throwsIllegalArg(function) { |
| 174 expect(function, throwsArgumentError); | 188 expect(function, throwsArgumentError); |
| 175 } | 189 } |
| 176 | 190 |
| 177 validateUsage(ArgParser parser, String expected) { | 191 validateUsage(ArgParser parser, String expected) { |
| 178 expected = unindentString(expected); | 192 expected = unindentString(expected); |
| 179 expect(parser.getUsage(), equals(expected)); | 193 expect(parser.getUsage(), equals(expected)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 206 throw new ArgumentError( | 220 throw new ArgumentError( |
| 207 'Line "$line" does not have enough indentation.'); | 221 'Line "$line" does not have enough indentation.'); |
| 208 } | 222 } |
| 209 | 223 |
| 210 lines[i] = line.substring(indent); | 224 lines[i] = line.substring(indent); |
| 211 } | 225 } |
| 212 } | 226 } |
| 213 | 227 |
| 214 return lines.join('\n'); | 228 return lines.join('\n'); |
| 215 } | 229 } |
| OLD | NEW |