Skip to content

Issue with POSIX short options #2147

Answered by remkop
ustieber asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you! Note that DemoOptionsHandlerTest incorrectly tests this:

// currently: passing an array with one element
DemoOptionsHandler.parse(new String[] { "-v 3" }); 

This results in the -v option getting the value of the string " 3" (space followed by the character '3')

I believe your intention is to test this:

// should: pass an array with two elements
DemoOptionsHandler.parse(new String[] { "-v", "3" });

That would be closer to what happens when the user invokes your command on the command line like this:

demo -v 3

The shell will tokenize the input and the main method of your application will receive an array with 2 elements, "-v" and "3".
I hope this clarifies.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ustieber
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants