diff --git a/docs/apidocs/picocli/CommandLine.IFactory.html b/docs/apidocs/picocli/CommandLine.IFactory.html new file mode 100644 index 000000000..1569828ca --- /dev/null +++ b/docs/apidocs/picocli/CommandLine.IFactory.html @@ -0,0 +1,239 @@ + + + +
+ +public static interface CommandLine.IFactory
+CommandLine.Command.subcommands()
, CommandLine.Option.converter()
, CommandLine.Parameters.converter()
and CommandLine.Command.versionProvider()
.Modifier and Type | +Method and Description | +
---|---|
<K> K |
+create(java.lang.Class<K> cls)
+Creates and returns an instance of the specified class.
+ |
+
<K> K create(java.lang.Class<K> cls) + throws java.lang.Exception+
K
- the type to instantiatecls
- the class to instantiatejava.lang.Exception
- an exception detailing what went wrong when creating the instancepublic static interface CommandLine.IVersionProvider
+CommandLine.Command.versionProvider()
annotation attribute.Modifier and Type | +Method and Description | +
---|---|
java.lang.String[] |
+getVersion()
+Returns version information for a command.
+ |
+
java.lang.String[] getVersion() + throws java.lang.Exception+
java.lang.Exception
- an exception detailing what went wrong when obtaining version information@Retention(value=RUNTIME)
+ @Target(value=FIELD)
+public static @interface CommandLine.ParentCommand
+
+ Fields annotated with @ParentCommand
will be initialized with the parent command of the current subcommand.
+ If the current command does not have a parent command, this annotation has no effect.
+
+ Parent commands often define options that apply to all the subcommands. + This annotation offers a convenient way to inject a reference to the parent command into a subcommand, so the + subcommand can access its parent options. For example: +
+ @Command(name = "top", subcommands = Sub.class) + class Top implements Runnable { + + @Option(names = {"-d", "--directory"}, description = "this option applies to all subcommands") + File baseDirectory; + + public void run() { System.out.println("Hello from top"); } + } + + @Command(name = "sub") + class Sub implements Runnable { + + @ParentCommand + private Top parent; + + public void run() { + System.out.println("Subcommand: parent command 'directory' is " + parent.baseDirectory); + } + } +