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", () { | 57 test("truncates newlines in command descriptions by default", () { |
58 runner.addCommand(new MultilineCommand()); | 58 runner.addCommand(new MultilineCommand()); |
59 | 59 |
60 expect(runner.usage, equals(""" | 60 expect(runner.usage, equals(""" |
61 A test command runner. | 61 A test command runner. |
62 | 62 |
63 Usage: test <command> [arguments] | 63 Usage: test <command> [arguments] |
64 | 64 |
65 Global options: | 65 Global options: |
66 -h, --help Print this usage information. | 66 -h, --help Print this usage information. |
67 | 67 |
68 Available commands: | 68 Available commands: |
69 help Display help information for test. | 69 help Display help information for test. |
70 multiline Multi | 70 multiline Multi |
| 71 |
| 72 Run "test help <command>" for more information about a command.""")); |
| 73 }); |
| 74 |
| 75 test("supports newlines in command summaries", () { |
| 76 runner.addCommand(new MultilineSummaryCommand()); |
| 77 |
| 78 expect(runner.usage, equals(""" |
| 79 A test command runner. |
| 80 |
| 81 Usage: test <command> [arguments] |
| 82 |
| 83 Global options: |
| 84 -h, --help Print this usage information. |
| 85 |
| 86 Available commands: |
| 87 help Display help information for test. |
| 88 multiline Multi |
71 line. | 89 line. |
72 | 90 |
73 Run "test help <command>" for more information about a command.""")); | 91 Run "test help <command>" for more information about a command.""")); |
74 }); | 92 }); |
75 | 93 |
76 test("contains custom options", () { | 94 test("contains custom options", () { |
77 runner.argParser.addFlag("foo", help: "Do something."); | 95 runner.argParser.addFlag("foo", help: "Do something."); |
78 | 96 |
79 expect(runner.usage, equals(""" | 97 expect(runner.usage, equals(""" |
80 A test command runner. | 98 A test command runner. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 315 |
298 expect(runner.run(["foo", "bar"]), throwsUsageError( | 316 expect(runner.run(["foo", "bar"]), throwsUsageError( |
299 'Command "foo" does not take any arguments.', """ | 317 'Command "foo" does not take any arguments.', """ |
300 Usage: test foo [arguments] | 318 Usage: test foo [arguments] |
301 -h, --help Print this usage information. | 319 -h, --help Print this usage information. |
302 | 320 |
303 Run "test help" to see global options.""")); | 321 Run "test help" to see global options.""")); |
304 }); | 322 }); |
305 }); | 323 }); |
306 } | 324 } |
OLD | NEW |