-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package picocli; | ||
|
||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.Option; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
// https://github.com/remkop/picocli/issues/1408 | ||
public class OrderedSynopsisTest { | ||
|
||
@Ignore("#1408") | ||
@Test | ||
public void testIssue1408() { | ||
@Command(name = "myCommand", | ||
mixinStandardHelpOptions = true, | ||
description = "A command with explicitly ordered options.", | ||
sortOptions = false) | ||
class Example { | ||
@Option(names = { "-d", "--option-d" }, order = -10, description = "Should be first") | ||
private void setD(String value) { | ||
this.d = value; | ||
} | ||
private String d; | ||
|
||
@Option(names = { "-c", "--option-c" }, order = -9, description = "Should be second") | ||
private void setC(String value) { | ||
this.c = value; | ||
} | ||
private String c; | ||
|
||
@Option(names = { "-b", "--option-b" }, order = -8, description = "Should be third") | ||
private String b; | ||
|
||
@Option(names = { "-a", "--option-a" }, order = -7, description = "Should be fourth") | ||
private String a; | ||
} | ||
String actual = new CommandLine(new Example()).getUsageMessage(CommandLine.Help.Ansi.OFF); | ||
String expected = String.format("" + | ||
"Usage: myCommand [-hV] [-d=<d>] [-c=<c>] [-b=<b>] [-a=<a>]%n" + | ||
"A command with explicitly ordered options.%n" + | ||
" -d, --option-d=<d> Should be first%n" + | ||
" -c, --option-c=<c> Should be second%n" + | ||
" -b, --option-b=<b> Should be third%n" + | ||
" -a, --option-a=<a> Should be fourth%n" + | ||
" -h, --help Show this help message and exit.%n" + | ||
" -V, --version Print version information and exit.%n"); | ||
assertEquals(expected, actual); | ||
} | ||
} |