I am making a Command Line program, I am using if conditions to check what the user entered and launch a specific method.
input = bufferedReader.readLine;
if (input.equals("search"))
search();
So as for now, to preform a search, the user must enter:
>>> search
>>> aTextToSearchFor
But I want the user to be able to enter
>>> search -c 3
so, 3
will be passed as a parameter to the search()
method
also, search
only should be valid and a default of 0
will be passed instead
Note:
- I am open to implement this without the
-c
, so the command will besearch 5
- I have found about Apache Commons CLI & Jcommander, but I can't find a simple enough explanation to understand any thing :D