Changelog
View SourceAll notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
v0.1.7 (2025-10-31)
Fixed
Fixed parsing of values starting with dashes (
-or--). The parser now correctly handles:- Negative numbers:
--number -10,--temperature -3.14 - String values starting with dash:
--password -abc123,--name -fgd*& - Values that look like undefined options:
--name --not-an-option
The parser is now schema-aware and only treats dash-prefixed values as options if they are actually defined in the schema. Previously, any value starting with
-was incorrectly treated as an option, causing parsing errors.Note: If a value matches a defined option (e.g.,
--name -vwhen-vis defined as a short option), it will still be treated as an option. See documentation for details and recommendations.- Negative numbers:
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
allowedflag whenmultipleis set totrue.
v0.1.4 (2025-02-07)
Added
Support defining mutually exclusive arguments through
:conflicts_withoption.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/3through an optional:post_validateoption.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
separatoroption 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
:envoption. 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_sectionto any option, and pass a:sectionsoption in theCliOptions.docs/2function for the headers and extended docs of each section.
v0.1.1 (2024-07-04)
Added
- If an option is set with
doc: falseit is not included in docs. - Support deprecating options with
:deprecated.
v0.1.0 (2024-05-13)
Initial release.