From 34f51d2c5409b73c09c2ed3282a62b6a1f7ad1bd Mon Sep 17 00:00:00 2001 From: Remko Popma Date: Wed, 20 Jun 2018 17:44:25 +0900 Subject: [PATCH] [#259] small doc fixes for @Inject --- docs/index.adoc | 2 +- src/main/java/picocli/CommandLine.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/index.adoc b/docs/index.adoc index bab6bc22f..a5d86a06c 100644 --- a/docs/index.adoc +++ b/docs/index.adoc @@ -2302,7 +2302,7 @@ Usage:
Custom handlers can extend `AbstractHandler` to inherit this behaviour. === `@Inject` Annotation -Picocli 3.2 introduces a custom `@Inject` annotation (not `javax.inject.Inject`) for injecting the `CommandSpec` model of the command into a command field. +Picocli 3.2 introduces a custom `@Inject` annotation (`picocli.CommandLine.Inject`, not `javax.inject.Inject`) for injecting the `CommandSpec` model of the command into a command field. This is useful when a command needs to use the picocli API, for example to walk the command hierarchy and iterate over its sibling commands. This complements the `@ParentCommand` annotation; the `@ParentCommand` annotation injects a user-defined command object, whereas this annotation injects a picocli class. diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index 7e1350723..9787f9ad5 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -2183,11 +2183,10 @@ private static class NoCompletionCandidates implements Iterable { String name() default ""; } /** - * Fields annotated with {@code @Inject} will be initialized with the {@code CommandLine} or {@code CommandSpec} for the command the field is part of. Example usage: + * Fields annotated with {@code @Inject} will be initialized with the {@code CommandSpec} for the command the field is part of. Example usage: *
      * class InjectExample implements Runnable {
-     *     @Inject CommandLine commandLine; // usually you inject either the CommandLine
-     *     @Inject CommandSpec commandSpec; // or the CommandSpec
+     *     @Inject CommandSpec commandSpec;
      *     //...
      *     public void run() {
      *         // do something with the injected objects