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.

Programatically added subcommands don't appear in help

See original GitHub issue

When I add my commands like this:

subcommands = {
    TransformCommand.class,
    ValidateCommand.class
}

This shows the help as it should be:

Commands:
  transform  Transforms ...
  validate   Validates ...

However, when I add them like this:

        commandLine.addSubcommand("transform", new TransformCommand());
        commandLine.addSubcommand("validate", new ValidateCommand());

Nothing appears in help, and to make things very ackward, the commands actually work when I call them, they are just not appearing in the help.

Am I missing something?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
remkopcommented, Dec 19, 2017

Glad to hear that!

By the way, since you are writing an application with subcommands you may be interested in the new @ParentCommand annotation that will be in the upcoming 2.2 release (hopefully end of this week).

For details, see https://github.com/remkop/picocli/wiki/Manual-(2.2.0-SNAPSHOT)#code-parentcommand-code-annotation

0reactions
vromerocommented, Dec 19, 2017

Actually I found my mistake while writing it. I was passing this instead of the actual command line when printing the help. That is why only when added as annotation worked.

Apologies for the unnecessary noise and THANKS! for the absolutely great piece of software. Would add a star now but already did!

Read more comments on GitHub >

github_iconTop Results From Across the Web

nested subcommands declared programatically not listed in ...
The intention is that the usage help prints all subcommands, regardless of whether they were added programmatically or declaratively.
Read more >
python - In django, how do I call the subcommand 'syncdb ...
All Django management commands can be accessed programmatically: from django.core.management import call_command call_command('syncdb', ...
Read more >
Programmatic API - Picocli
The subcommand method returns a different ParseResult object that can be used to query which options and positional parameters were matched for ...
Read more >
django-admin and manage.py
Run django-admin help to display usage information and a list of the commands provided by each application. Run django-admin help --commands to display...
Read more >
Tutorial: Get started with System.CommandLine
CommandLine package; Test the app; Add a subcommand and options ... --version Show version information -?, -h, --help Show help and usage ...
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