-
Notifications
You must be signed in to change notification settings - Fork 428
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
Support @Spec annotation to inject CommandSpec into command implementation #259
Comments
@remkop Nice addition. First at all, I didn't try why I will speak about, is just theoretical analysis. But currently on picocli-spring-boot-starter commands use to be a Spring component/bean. And Spring in addition to But
What do you think about? How we can solve that? I think with alternative and more old school way to inject that component for example by implementing a picocli |
I think Spring is looking for the If a class uses both the picocli and the javax |
Lol my bad I read to quickly I though it was |
No worries. Thanks for checking! |
Are you not afraid that people will have confusion between both annotations, and some of them will still import |
Yes there is some risk there. The benefits are no external dependency and a name that is intuitively obvious in what it does. So there’s a trade-off. I’ll add a note in the documentation. Thanks for pointing this out. |
It turns out that the custom HelpCommand use case also required that the Reconsidering defining a |
…application field." This reverts commit 2cb8d66
…ommandLine` into application field." This reverts commit a781f80
I'm also looking for a way to "help subcommand" properly. |
@fcorneli Can you try with current master? |
Picocli 3.0 (in master) has a built-in help command that can give help on a specified subcommand or on the preceding command. See https://github.com/remkop/picocli/wiki/Manual-(3.0.0-SNAPSHOT)#built-in-help-subcommand |
FYI: I ran into a use case that requires access to the picocli command model from the application, so this will be available from picocli 3.2. The use case has to do with JLine completion candidates (#393, also in v3.2). |
…o use `@PicoInject` for a limited form of Dependency Injection later
See for example the auto-help use case: a
command help subcommand
command should print help for the specified subcommand of the parent command. This means it needs to obtain a subcommandCommandLine
orCommandSpec
object from the parent command. The@ParentCommand
annotation does not work because it injects the user-defined command object, not the picocli class.Another use cases is custom commands that need to know exactly which options were actually specified on the command line. This could be accomplished by injecting the
ParseResult
(#257).A generic
@Inject
annotation is generic and flexible enough to allow future extensions, while at the same time the meaning is intuitively clear to many users because of its similarity to JSR-330 (javax.inject.Inject
).The text was updated successfully, but these errors were encountered: