package minicli

  1. Overview
  2. Docs
Minimalist library for command line parsing

Install

Dune Dependency

Authors

Maintainers

Sources

v5.0.0.tar.gz
sha256=66833cd577d672db9b580b8db1cdbb59596d66e380a6c6ee6eb2db5f2e4acffb
md5=0aa4a3ce11d9554c755cf75b6ba50237

Description

minicli provides the CLI module. It allows programmers to quickly and correctly handle options passed via the command line to their program. minicli is intended at people who develop software fast, but who don't want to break things. minicli can throw a variety of informative exceptions to the end user, when the command line interface is not being used correctly. So that, the end user has a good chance to correct himself before calling for the software support team. Another design goals of minicli is to make command-line scientific programs harder to use incorrectly.

Published: 11 Dec 2018

README

minicli

Minimalist OCaml library for command line parsing. Look into the test.ml file for usage examples/quickstart.

example session with the test program

# ./test
usage:
./test {-i|--input} <file> {-o|--output} <file> -n <int> -x <float> [-v] [--hi <string>]

# ./test -i
Fatal error: exception CLI.No_param_for_option("-i")

# ./test -i input.txt
Fatal error: exception CLI.Option_is_mandatory("-o")

# ./test -i input.txt -o output.txt
Fatal error: exception CLI.Option_is_mandatory("-n")

# ./test -i input.txt -o output.txt -n /dev/null
Fatal error: exception CLI.Not_an_int("/dev/null")

# ./test -i input.txt -o output.txt -n 123
Fatal error: exception CLI.Option_is_mandatory("-x")

# ./test -i input.txt -o output.txt -n 123 -x /dev/null
Fatal error: exception CLI.Not_a_float("/dev/null")

# ./test -i input.txt -o output.txt -n 123 -x 0.123
i: input.txt o: output.txt n: 123 x: 0.123000 v: false

# ./test -i input.txt -o output.txt -n 123 -x 0.123 -v
i: input.txt o: output.txt n: 123 x: 0.123000 v: true

# ./test -i input.txt -o output.txt -n 123 -x 0.123 -v -i input.bin
Fatal error: exception CLI.More_than_once("-i, --input")

Dependencies (2)

  1. dune < "2.0"
  2. ocaml

Dev Dependencies

None

Conflicts

None

OCaml

Innovation. Community. Security.