Set description for command, but not for option
See original GitHub issueFor every command I have a concrete class which implements certain interface. For example:
public class FooCommand implements Command{
@Parameter(names = {"-?","--help"}, description = "display this help",help = true)
private boolean helpRequested = false;
}
I have foo-command, boo-command, lala-command. However, all these commands are separate and are not within one main command (by other words this is not like git clone …). This is the way I get usage
JCommander jCommander=new JCommander(command, args);
jCommander.setProgramName(commandName);//for example foo-command
StringBuilder builder=new StringBuilder();
jCommander.usage(builder);
And this is the usage message I get:
Usage: foo-command [options]
Options:
-?, --help
display this help
However I need to add description to command (but not to option). For example I want to get such usage message:
Usage: foo-command [options] - This command is used as base foo
Options:
-?, --help
display this help
To get it I do this way:
public class FooCommand implements Command{
@Parameter(names = {"-?","--help"}, description = "display this help",help = true)
private boolean helpRequested = false;
@Parameter(description = "This command is used as base foo")
private String usage=null;//this field is only for setting parameter
}
The code seems to work, but I don’t like that there is a field usage that is not used. Maybe it is better to add support for such cases?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:11 (1 by maintainers)
Top Results From Across the Web
How to set description for command, but not for option
1 Answer 1 ; @Parameters(commandDescription = "foo-command short description") public class FooCommand implements ; Command · @Parameter(names = {" ...
Read more >Set or unset command options and positional parameters - IBM
Description. Calling set without arguments displays the names and values of all shell variables, sorted by name, in the following format: Variable ...
Read more >Chapter 33. Options
Options are settings that change shell and/or script behavior. The set command enables options within a script. At the point in the script...
Read more >Adding arguments and options to your Bash scripts - Red Hat
This help function will display a short description of the program, a syntax diagram, and a short description of each available option.
Read more >Options Summary (GNU make) - GNU.org
9.8 Summary of Options. Here is a table of all the options make understands: ' -b ': ' -m '. These options are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Having the possibility to display a global description of the command along with the help message. I also miss this feature a lot!
Dear @PashaTurok,
As you can see it is possible through a change to JCommander.
But it’s up to @cbeust if he considers the change necessary or not.
😄