Changelog
View SourceAll notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
v0.1.6 (2025-04-03)
Fixed
- Properly format default values in docs when they are lists.
- Fix default values validation when allowed is set.
v0.1.5 (2025-03-28)
Fixed
- Support
allowed
flag whenmultiple
is set totrue
.
v0.1.4 (2025-02-07)
Added
Support defining mutually exclusive arguments through
:conflicts_with
option.iex> schema = [ ...> verbose: [type: :boolean, conflicts_with: [:silent]], ...> silent: [type: :boolean] ...> ] ...> ...> CliOptions.parse(["--verbose", "--silent"], schema) {:error, "--verbose is mutually exclusive with --silent"}
Support post validation of the parsed options in
CliOptions.parse/3
through an optional:post_validate
option.iex> schema = [ ...> silent: [type: :boolean], ...> verbose: [type: :boolean] ...> ] ...> ...> # the flags --verbose and --silent should not be set together ...> post_validate = ...> fn {opts, args, extra} -> ...> if opts[:verbose] and opts[:silent] do ...> {:error, "flags --verbose and --silent cannot be set together"} ...> else ...> {:ok, {opts, args, extra}} ...> end ...> end ...> ...> # without post_validate ...> CliOptions.parse(["--verbose", "--silent"], schema) {:ok, {[silent: true, verbose: true], [], []}} iex> # with post_validate ...> CliOptions.parse(["--verbose", "--silent"], schema, post_validate: post_validate) {:error, "flags --verbose and --silent cannot be set together"} iex> # if only one of the two is passed the validation succeeds ...> CliOptions.parse(["--verbose"], schema, post_validate: post_validate) {:ok, {[silent: false, verbose: true], [], []}}
v0.1.3 (2024-10-18)
Added
Support providing repeating arguments with a separator. If you set the
separator
option for an argument's schema you can pass the values in the format--arg value1<sep>value2
. For example, for the following schema:schema = [ name: [ type: :string, multiple: true, separator: ";" ]
all of the following invocation are valid and equivalent:
# passing the arg multiple times $ mix foo --name john --name jack --name paul # passing the arg once with the values separated with ; $ mix foo --name john;jack;paul # a combination of the above $ mix foo --name john --name jack;paul
v0.1.2 (2024-07-12)
Added
Support getting option value from an environment variable, through the
:env
option. Used only if not provided by the user in the CLI arguments.Support grouping options in the docs by section. You can now specify the
:doc_section
to any option, and pass a:sections
option in theCliOptions.docs/2
function for the headers and extended docs of each section.
v0.1.1 (2024-07-04)
Added
- If an option is set with
doc: false
it is not included in docs. - Support deprecating options with
:deprecated
.
v0.1.0 (2024-05-13)
Initial release.