Class ManPageGenerator

java.lang.Object
picocli.codegen.docgen.manpage.ManPageGenerator
All Implemented Interfaces:
Callable<Integer>

public class ManPageGenerator extends Object implements Callable<Integer>
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Invokes generateManPage(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 the customizablePagesDirectory directory.
    static void
    main(String[] args)
    Invokes generateManPage(Config, CommandLine.Model.CommandSpec...) to generate man pages for the user-specified @Command-annotated classes.
    static void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ManPageGenerator

      public ManPageGenerator()
  • Method Details

    • call

      public Integer call() throws IOException
      Invokes generateManPage(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 interface Callable<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

      public static void main(String[] args)
      Invokes generateManPage(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 the customizablePagesDirectory 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 processing
      overwriteCustomizablePages - 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

      public static void writeSingleManPage(PrintWriter pw, CommandLine.Model.CommandSpec spec)