View Source erlarg (erlarg v1.0.1)

Summary

Functions

Retuns the specification for an option Name that doesn't have parameter.

Return the specification for an option Name that must be parsed with Syntax.

Parses arguments into a structured data according to a given syntax
Parses arguments into a structured data according to a given syntax and aliases

Types

args/0

-type args() :: [string()].

opt/0

-opaque opt()

option_name/0

-type option_name() :: {string() | undefined, string() | undefined} | string().

syntax/0

-opaque syntax()

Functions

opt(Option, Name)

-spec opt(Option, Name) -> Return
             when
                 Option :: option_name() | undefined,
                 Name :: atom(),
                 Return :: opt() | {atom(), syntax()}.

Retuns the specification for an option Name that doesn't have parameter.

Example:
 --help % also -h
 erlarg:opt({"-h", "--help"}, help).

opt(Option, Name, Syntax)

-spec opt(Option, Name, Syntax) -> Return
             when
                 Option :: option_name() | undefined,
                 Name :: atom(),
                 Syntax :: syntax() | undefined,
                 Return :: opt() | {atom(), syntax()}.

Return the specification for an option Name that must be parsed with Syntax.

Example:
 date -d 'now'
 erlarg:opt({"-d", "--date"}, date, string()).

parse(Args, Syntax)

-spec parse(Args, Syntax) -> Options | Error
               when Args :: args(), Syntax :: syntax(), Options :: {ok, {any(), args()}}, Error :: error.
Parses arguments into a structured data according to a given syntax

parse(Args, Syntax, Aliases)

-spec parse(Args, Syntax, Aliases) -> Options | Error
               when
                   Args :: args(),
                   Syntax :: syntax(),
                   Aliases :: map(),
                   Options :: {ok, {any(), args()}},
                   Error :: error.
Parses arguments into a structured data according to a given syntax and aliases