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

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

Issue 203273013: Ignore hidden options when calculating usage columns. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months 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 void main() { 10 void main() {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 test("hidden options 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 184
185 test("hidden flags don't appear in the help", () { 185 test("hidden flags don't appear in the help", () {
186 var parser = new ArgParser(); 186 var parser = new ArgParser();
187 parser.addFlag('first', help: 'The first flag'); 187 parser.addFlag('first', help: 'The first flag');
188 parser.addFlag('second', hide: true); 188 parser.addFlag('second', hide: true);
189 parser.addFlag('third', help: 'The third flag'); 189 parser.addFlag('third', help: 'The third flag');
190 190
191 191
192 validateUsage(parser, 192 validateUsage(parser,
193 ''' 193 '''
194 --[no-]first The first flag 194 --[no-]first The first flag
195 --[no-]third The third flag 195 --[no-]third The third flag
196 ''');
197 });
198
199 test("hidden options don't affect spacing", () {
200 var parser = new ArgParser();
201 parser.addFlag('first', help: 'The first flag');
202 parser.addFlag('second-very-long-option', hide: true);
203 parser.addFlag('third', help: 'The third flag');
204
205
206 validateUsage(parser,
207 '''
208 --[no-]first The first flag
209 --[no-]third The third flag
196 '''); 210 ''');
197 }); 211 });
198 }); 212 });
199 } 213 }
200 214
201 void validateUsage(ArgParser parser, String expected) { 215 void validateUsage(ArgParser parser, String expected) {
202 expected = unindentString(expected); 216 expected = unindentString(expected);
203 expect(parser.getUsage(), equals(expected)); 217 expect(parser.getUsage(), equals(expected));
204 } 218 }
205 219
(...skipping 24 matching lines...) Expand all
230 throw new ArgumentError( 244 throw new ArgumentError(
231 'Line "$line" does not have enough indentation.'); 245 'Line "$line" does not have enough indentation.');
232 } 246 }
233 247
234 lines[i] = line.substring(indent); 248 lines[i] = line.substring(indent);
235 } 249 }
236 } 250 }
237 251
238 return lines.join('\n'); 252 return lines.join('\n');
239 } 253 }
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