OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'package:args/command_runner.dart'; | 5 import 'package:args/command_runner.dart'; |
6 import 'package:test/test.dart'; | 6 import 'package:test/test.dart'; |
7 | 7 |
8 import 'utils.dart'; | 8 import 'utils.dart'; |
9 | 9 |
10 const _DEFAULT_USAGE = """ | 10 const _DEFAULT_USAGE = """ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 Global options: | 47 Global options: |
48 -h, --help Print this usage information. | 48 -h, --help Print this usage information. |
49 | 49 |
50 Available commands: | 50 Available commands: |
51 foo Set a value. | 51 foo Set a value. |
52 help Display help information for test. | 52 help Display help information for test. |
53 | 53 |
54 Run "test help <command>" for more information about a command.""")); | 54 Run "test help <command>" for more information about a command.""")); |
55 }); | 55 }); |
56 | 56 |
| 57 test("supports newlines in command descriptions", () { |
| 58 runner.addCommand(new MultilineCommand()); |
| 59 |
| 60 expect(runner.usage, equals(""" |
| 61 A test command runner. |
| 62 |
| 63 Usage: test <command> [arguments] |
| 64 |
| 65 Global options: |
| 66 -h, --help Print this usage information. |
| 67 |
| 68 Available commands: |
| 69 help Display help information for test. |
| 70 multiline Multi |
| 71 line. |
| 72 |
| 73 Run "test help <command>" for more information about a command.""")); |
| 74 }); |
| 75 |
57 test("contains custom options", () { | 76 test("contains custom options", () { |
58 runner.argParser.addFlag("foo", help: "Do something."); | 77 runner.argParser.addFlag("foo", help: "Do something."); |
59 | 78 |
60 expect(runner.usage, equals(""" | 79 expect(runner.usage, equals(""" |
61 A test command runner. | 80 A test command runner. |
62 | 81 |
63 Usage: test <command> [arguments] | 82 Usage: test <command> [arguments] |
64 | 83 |
65 Global options: | 84 Global options: |
66 -h, --help Print this usage information. | 85 -h, --help Print this usage information. |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 297 |
279 expect(runner.run(["foo", "bar"]), throwsUsageError( | 298 expect(runner.run(["foo", "bar"]), throwsUsageError( |
280 'Command "foo" does not take any arguments.', """ | 299 'Command "foo" does not take any arguments.', """ |
281 Usage: test foo [arguments] | 300 Usage: test foo [arguments] |
282 -h, --help Print this usage information. | 301 -h, --help Print this usage information. |
283 | 302 |
284 Run "test help" to see global options.""")); | 303 Run "test help" to see global options.""")); |
285 }); | 304 }); |
286 }); | 305 }); |
287 } | 306 } |
OLD | NEW |