Module Cmdliner.Manpage

Contents

Instructions: Use this module in your project

In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:

  1. Add the following to your project's dependencies/CMakeLists.txt:

    Copy
    DkSDKProject_DeclareAvailable(cmdliner
        CONSTRAINT "= 1.1.1+dune"
        FINDLIBS cmdliner)
    DkSDKProject_MakeAvailable(cmdliner)
  2. Add the Findlib::cmdliner library to any desired targets in src/*/CMakeLists.txt:

    Copy
    target_link_libraries(YourPackage_YourLibraryName
         # ... existing libraries, if any ...
         Findlib::cmdliner)
  3. Click your IDE's Build button

Not using DkSDK?

FIRST, do one or all of the following:

  1. Run:

    Copy
    opam install cmdliner.1.1.1+dune
  2. Edit your dune-project and add:

    Copy
    (package
      (name YourExistingPackage)
      (depends
      ; ... existing dependenices ...
      (cmdliner (>= 1.1.1+dune))))

    Then run:

    Copy
    dune build *.opam # if this fails, run: dune build
  3. Edit your <package>.opam file and add:

    Copy
    depends: [
      # ... existing dependencies ...
      "cmdliner" {>= "1.1.1+dune"}
    ]

    Then run:

    Copy
    opam install . --deps-only

FINALLY, add the cmdliner library to any desired (library)and/or (executable) targets in your **/dune files:

Copy
(library
  (name YourLibrary)
  ; ... existing library options ...
  (libraries
    ; ... existing libraries ...
    cmdliner))

(executable
  (name YourExecutable)
  ; ... existing executable options ...
  (libraries
    ; ... existing libraries ...
    cmdliner))

Man pages

typeblock`` = ``[
| ``` S ``of string
| ``` P ``of string
| ``` Pre ``of string
| ``` I ``of string * string
| ``` Noblank ``
| ``` Blocks ``of block list ]

The type for a block of man page text.

  • `S s introduces a new section s, see the standard section names.
  • `P t is a new paragraph with text t.
  • `Pre t is a new preformatted paragraph with text t.
  • `I (l,t) is an indented paragraph with label l and text t.
  • `Noblank suppresses the blank line introduced between two blocks.
  • `Blocks bs splices the blocks bs.

Except in `Pre, whitespace and newlines are not significant and are all collapsed to a single space. All block strings support the documentation markup language.

valescape : ``string-> string

escape s escapes s so that it doesn't get interpreted by the documentation markup language.

type title`` = string * int * string * string * string

The type for man page titles. Describes the man page title, section, center_footer, left_footer, center_header.

typet`` =title*block list

The type for a man page. A title and the page text as a list of blocks.

typexref`` = ``[
| ``` Main ``
| ``` Cmd ``of string
| ``` Tool ``of string
| ``` Page ``of string * int ]

The type for man page cross-references.

  • `Main refers to the man page of the program itself.
  • `Cmd cmd refers to the man page of the program's cmd command (which must exist).
  • `Tool bin refers to the command line tool named bin.
  • `Page (name, sec) refers to the man page name(sec).

Standard section names and content

The following are standard man page section names, roughly ordered in the order they conventionally appear. See also man man-pages for more elaborations about what sections should contain.

val s_name : string

The NAME section. This section is automatically created by Cmdliner for your.

val s_synopsis : string

The SYNOPSIS section. By default this section is automatically created by Cmdliner for you, unless it is the first section of your term's man page, in which case it will replace it with yours.

val s_description : string

The DESCRIPTION section. This should be a description of what the tool does and provide a little bit of usage and documentation guidance.

val s_commands : string

The COMMANDS section. By default subcommands get listed here.

val s_arguments : string

The ARGUMENTS section. By default positional arguments get listed here.

val s_options : string

The OPTIONS section. By default optional arguments get listed here.

val s_common_options : string

The COMMON OPTIONS section. By default help and version options get listed here. For programs with multiple commands, optional arguments common to all commands can be added here.

val s_exit_status : string

The EXIT STATUS section. By default term status exit codes get listed here.

val s_environment : string

The ENVIRONMENT section. By default environment variables get listed here.

vals_environment_intro :block

s_environment_intro is the introduction content used by cmdliner when it creates the s_environment section.

val s_files : string

The FILES section.

val s_bugs : string

The BUGS section.

val s_examples : string

The EXAMPLES section.

val s_authors : string

The AUTHORS section.

val s_see_also : string

The SEE ALSO section.

val s_none : string

s_none is a special section named "cmdliner-none" that can be used whenever you do not want something to be listed.

Output

The print function can be useful if the client wants to define other man pages (e.g. to implement a help command).

typeformat`` = ``[
| ``` Auto ``
| ``` Pager ``
| ``` Plain ``
| ``` Groff `` ]

The type for man page output specification.

  • `Auto, formats like `Pager or `Plain whenever the TERM environment variable is dumb or unset.
  • `Pager, tries to write to a discovered pager, if that fails uses the `Plain format.
  • `Plain, formats to plain text.
  • `Groff, formats to groff commands.
val print : ``?errs:Stdlib.Format.formatter ->``?subst:``(``string->``string option``)``-> format -> Stdlib.Format.formatter -> t -> unit

print ~errs ~subst fmt ppf page prints page on ppf in the format fmt. subst can be used to perform variable substitution,(defaults to the identity). errs is used to print formatting errors, it defaults to Format.err_formatter.

More from the DkSDK Book

    1. DkSDK
      1. Package capnp
        1. Module Capnp
            1. Module type MessageSig.MESSAGE
            1. Module type MessageSig.S
              1. Module S.ListStorage
              1. Module S.Message
              1. Module S.Object
              1. Module S.Segment
              1. Module S.Slice
              1. Module S.StructStorage
            1. Module type MessageSig.SEGMENT
            1. Module type MessageSig.SLICE
        1. Module Capnp_unix
      1. Package cmdliner
        1. Module Cmdliner
          1. ...
          1. Module Cmdliner.Manpage
          1. ...
        1. Module Cmdliner_arg
        1. Module Cmdliner_base
        1. Module Cmdliner_cline
        1. Module Cmdliner_cmd
        1. Module Cmdliner_docgen
        1. Module Cmdliner_eval
        1. Module Cmdliner_info
        1. Module Cmdliner_manpage
        1. Module Cmdliner_msg
        1. Module Cmdliner_term
        1. Module Cmdliner_term_deprecated
        1. Module Cmdliner_trie
      1. Package fmt
        1. Module Fmt
        1. Module Fmt_cli
        1. Module Fmt_tty
      1. Package logs
        1. Module Logs
          1. Module type Logs.LOG
          1. ...
        1. Module Logs_cli
        1. Module Logs_fmt
        1. Module Logs_lwt
          1. Module type Logs_lwt.LOG
        1. Module Logs_threaded
      1. Package lwt
        1. Module Lwt
        1. Module Lwt_bytes
        1. Module Lwt_condition
        1. Module Lwt_config
        1. Module Lwt_engine
        1. Module Lwt_features
        1. Module Lwt_fmt
        1. Module Lwt_gc
        1. Module Lwt_io
            1. Module type Lwt_io.NumberIO
        1. Module Lwt_list
        1. Module Lwt_main
            1. Module type Lwt_main.Hooks
        1. Module Lwt_mutex
        1. Module Lwt_mvar
        1. Module Lwt_pool
        1. Module Lwt_pqueue
            1. Module type Lwt_pqueue.OrderedType
            1. Module type Lwt_pqueue.S
        1. Module Lwt_preemptive
        1. Module Lwt_process
        1. Module Lwt_result
        1. Module Lwt_seq
        1. Module Lwt_sequence
        1. Module Lwt_stream
        1. Module Lwt_switch
        1. Module Lwt_sys
        1. Module Lwt_throttle
            1. Module type Lwt_throttle.S
        1. Module Lwt_timeout
        1. Module Lwt_unix
      1. Package mtime
        1. Module Mtime
        1. Module Mtime_clock
      1. Package ocaml
        1. Module Bigarray
        1. Module Condition
        1. Module Dynlink
        1. Module Event
        1. Module Mutex
        1. Module Profiling
        1. Module Semaphore
        1. Module Stdlib
        1. Module Str
        1. Module Thread
        1. Module ThreadUnix
        1. Module Topdirs
        1. Module Unix
        1. Module UnixLabels
      1. Package
      1. Package result
        1. Module Result
      1. Package stdint
        1. Module Stdint
            1. Module type Stdint.Int