Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--help breaks when using required options when using singleCommand() #44

Open
burtonator opened this issue Sep 10, 2015 · 3 comments
Open

Comments

@burtonator
Copy link

If I have:

@Option(name = { "--sourceIndexes"}, description = "Source indexes to read from.", required = true)
public List<String> sourceIndexes;

and then do --help it tells me:

io.airlift.airline.ParseOptionMissingException: Required option '--targetIndex' is missing

... but if I remove required=true

I'll get the proper help output.

which is not fun because for our use case this breaks airline. Though I might see if I can work around this.

@ajs6f
Copy link

ajs6f commented Feb 26, 2017

I have the same problem. Perhaps it would be possible to have a notion of "required when X is not present"? That could actually be more valuable than just this use case.

@ajs6f
Copy link

ajs6f commented Feb 26, 2017

Meanwhile, the pattern I am currently using is:

final SingleCommand<Tool> cliParser = singleCommand(MyCommand.class);
try {
    final Tool tool = cliParser.parse(args);
    tool.run();
} catch (ParseOptionMissingException e) {
    help(cliParser.getCommandMetadata());
    }
}

where help is com.github.rvesse.airline.help.Help.help(CommandMetadata).

@findepi
Copy link
Contributor

findepi commented May 30, 2018

This apparently duplicates #22

nastra pushed a commit to k8ssandra/management-api-for-apache-cassandra that referenced this issue Mar 30, 2020
This is unfortunately due to a bug in airline itself
(airlift/airline#44). So it's easier to just
have a workaround in place when printing the help message.
tjake pushed a commit to k8ssandra/management-api-for-apache-cassandra that referenced this issue Mar 30, 2020
* Improve README

* Don't print usage errors when using -h/--help

This is unfortunately due to a bug in airline itself
(airlift/airline#44). So it's easier to just
have a workaround in place when printing the help message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants