Module Cmdliner_base

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))
valuid : ``unit-> int

uid () is new unique for the program run.

valsuggest : ``string->``string list``-> ``string list

suggest near candidates suggest values from candidates not too far from near.

Formatting helpers

valpp_text :Stdlib.Format.formatter ->``string-> unit
valpp_lines :Stdlib.Format.formatter ->``string-> unit
valpp_tokens : ``spaces:bool-> Stdlib.Format.formatter ->``string-> unit

Error message helpers

valquote : ``string-> string
valalts_str : ``?quoted:bool->``string list``-> string
valerr_ambiguous : ``kind:string->``string->``ambs:``string list``-> string
valerr_unknown : ``?dom:``string list``->``?hints:``string list``->``kind:string->``string-> string
valerr_multi_def : ``kind:string->``string-> ``('b ->string)``-> 'b -> 'b -> string

Textual OCaml value converters

type``'a parser`` = ``string->``[ ```Ok of  ````'a``` |Error ``` of string ```` ]`
type``'a printer`` =Stdlib.Format.formatter -> 'a -> unit
type``'a conv`` ='a parser*'a printer
valsome : ``?none:string-> 'a conv -> 'aoption``conv
val some' : ``?none:'a -> 'a conv -> 'aoption``conv
valbool : ``boolconv
valchar : ``charconv
valint : ``intconv
valnativeint : ``nativeintconv
valint32 : ``int32conv
valint64 : ``int64conv
valfloat : ``floatconv
valstring : ``stringconv
valenum : ``(string *'a)`` list`` -> 'a conv
valfile : ``stringconv
valdir : ``stringconv
valnon_dir_file : ``stringconv
vallist : ``?sep:char-> 'a conv -> 'alist``conv
valarray : ``?sep:char-> 'a conv -> 'aarray``conv
valpair : ``?sep:char-> 'a conv -> 'b conv -> ``('a*'b)`` conv
valt2 : ``?sep:char-> 'a conv -> 'b conv -> ``('a*'b)`` conv
valt3 : ``?sep:char-> 'a conv -> 'b conv -> 'c conv -> ``('a*'b*'c)`` conv
valt4 : ``?sep:char-> 'a conv -> 'b conv -> 'c conv -> 'd conv -> ``('a*'b*'c*'d)`` conv
valenv_bool_parse : ``boolparser