Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: pkg/args/test/usage_test.dart

Issue 82213002: Add a [hide] argument to [ArgParser.addFlag]. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/args/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 170
171 test("hidden flags don't appear in the help", () { 171 test("hidden options don't appear in the help", () {
172 var parser = new ArgParser(); 172 var parser = new ArgParser();
173 parser.addOption('first', help: 'The first option'); 173 parser.addOption('first', help: 'The first option');
174 parser.addOption('second', hide: true); 174 parser.addOption('second', hide: true);
175 parser.addOption('third', help: 'The third option'); 175 parser.addOption('third', help: 'The third option');
176 176
177 177
178 validateUsage(parser, 178 validateUsage(parser,
179 ''' 179 '''
180 --first The first option 180 --first The first option
181 --third The third option 181 --third The third option
182 '''); 182 ''');
183 }); 183 });
184
185 test("hidden flags don't appear in the help", () {
186 var parser = new ArgParser();
187 parser.addFlag('first', help: 'The first flag');
188 parser.addFlag('second', hide: true);
189 parser.addFlag('third', help: 'The third flag');
190
191
192 validateUsage(parser,
193 '''
194 --[no-]first The first flag
195 --[no-]third The third flag
196 ''');
197 });
184 }); 198 });
185 } 199 }
186 200
187 throwsIllegalArg(function) { 201 throwsIllegalArg(function) {
188 expect(function, throwsArgumentError); 202 expect(function, throwsArgumentError);
189 } 203 }
190 204
191 validateUsage(ArgParser parser, String expected) { 205 validateUsage(ArgParser parser, String expected) {
192 expected = unindentString(expected); 206 expected = unindentString(expected);
193 expect(parser.getUsage(), equals(expected)); 207 expect(parser.getUsage(), equals(expected));
(...skipping 26 matching lines...) Expand all
220 throw new ArgumentError( 234 throw new ArgumentError(
221 'Line "$line" does not have enough indentation.'); 235 'Line "$line" does not have enough indentation.');
222 } 236 }
223 237
224 lines[i] = line.substring(indent); 238 lines[i] = line.substring(indent);
225 } 239 }
226 } 240 }
227 241
228 return lines.join('\n'); 242 return lines.join('\n');
229 } 243 }
OLDNEW
« no previous file with comments | « pkg/args/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698