question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set description for command, but not for option

See original GitHub issue

For 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
raubelcommented, Jun 16, 2018

Having the possibility to display a global description of the command along with the help message. I also miss this feature a lot!

0reactions
jeremysolarzcommented, Jun 4, 2017

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.

😄

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found