Package picocli.codegen.docgen.manpage
Class ManPageGenerator
java.lang.Object
picocli.codegen.docgen.manpage.ManPageGenerator
Generates AsciiDoc files in a special format that can be converted to HTML, PDF and Unix Man pages.
This class can be used as a subcommand, in which case it generates man pages for all
non-hidden commands in the hierarchy from the top-level command down,
or it can be executed as a stand-alone tool, in which case the user needs to specify
the @Command
-annotated classes to generate man pages for.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall()
InvokesgenerateManPage(Config, CommandLine.Model.CommandSpec...)
to generate man pages for all non-hidden commands in the hierarchy from the top-level command down.static int
generateManPage
(File outdir, File customizablePagesDirectory, boolean[] verbosity, boolean overwriteCustomizablePages, CommandLine.Model.CommandSpec... specs) Generates AsciiDoc files for the specified classes to the specified output directory, optionally also generating template files in thecustomizablePagesDirectory
directory.static void
InvokesgenerateManPage(Config, CommandLine.Model.CommandSpec...)
to generate man pages for the user-specified@Command
-annotated classes.static void
-
Constructor Details
-
ManPageGenerator
public ManPageGenerator()
-
-
Method Details
-
call
InvokesgenerateManPage(Config, CommandLine.Model.CommandSpec...)
to generate man pages for all non-hidden commands in the hierarchy from the top-level command down. This method is only called when this class is used as a subcommand.- Specified by:
call
in interfaceCallable<Integer>
- Returns:
- an exit code indicating success or failure, as follows:
- 0: Successful program execution.
- 1: A runtime exception occurred while generating man pages.
- 2: Usage error: user input for the command was incorrect, e.g., the wrong number of arguments, a bad flag, a bad syntax in a parameter, etc.
- 4: A template file exists in the template directory. (Remove the `--template-dir` option or use `--force` to overwrite.)
- Throws:
IOException
- if a problem occurred writing files.
-
main
InvokesgenerateManPage(Config, CommandLine.Model.CommandSpec...)
to generate man pages for the user-specified@Command
-annotated classes.If the
--exit
option is specified,System.exit
is invoked afterwards with an exit code as follows:- 0: Successful program execution.
- 1: A runtime exception occurred while generating man pages.
- 2: Usage error: user input for the command was incorrect, e.g., the wrong number of arguments, a bad flag, a bad syntax in a parameter, etc.
- 4: A template file exists in the template directory. (Remove the `--template-dir` option or use `--force` to overwrite.)
- Parameters:
args
- command line arguments to be parsed. Must include the classes to generate man pages for.
-
generateManPage
public static int generateManPage(File outdir, File customizablePagesDirectory, boolean[] verbosity, boolean overwriteCustomizablePages, CommandLine.Model.CommandSpec... specs) throws IOException Generates AsciiDoc files for the specified classes to the specified output directory, optionally also generating template files in thecustomizablePagesDirectory
directory.- Parameters:
outdir
- Output directory to write the generated AsciiDoc files to.customizablePagesDirectory
- Optional directory to write customizable man page template files. If non-null
, an additional "template" file is created here for each generated manpage AsciiDoc file.verbosity
- the length of this array determines verbosity during processingoverwriteCustomizablePages
- Overwrite existing man page templates. The default is false, meaning processing is aborted and the process exits with status code 4 if a man page template file already exists.specs
- the Commands to generate AsciiDoc man pages for- Returns:
- the exit code
- Throws:
IOException
- if a problem occurred writing to the file system
-
writeSingleManPage
-