arguments

Argument parser for Elixir

Latest version: 0.1.0 registry icon
Maintenance score
0
Safety score
0
Popularity score
1
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.1.0 0 0 0 0 0

Stability
Latest release:

0.1.0 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

Apache-2.0   -   Apache License 2.0

Not a wildcard

Not proprietary

OSI Compliant



Arguments

Arguments parses command line arguments with a declarative, simple setup

Produces results as a map for super pattern matching argument handling in your app!

$ cmd new myname --more into %{new: true, name: "myname", more: true}

Documentation: https://hexdocs.pm/arguments/

Installation

Add arguments to your list of dependencies in mix.exs:

def deps do
  [{:arguments, "~> 0.1.0"}]
end

Usage

Arguments provides a module with argument parsing through YourArguments.parse(incoming)

use Arguments

There are two styles of arguments allowed

These two styles can be mixed, but the flags will always take priority

Full Example:

module MyArguments do
  use Arguments

  command "new", do: [
    arguments: [:name, :dir]
  ]

  flag "name", do: [
    type: :string,
    alias: :n,
    defaults: fn (n) -> [
      dir: "./#\{n\}"
    ] end
  ]

  flag "more", do: %{
    type: :boolean,
    alias: :m
  }

  flag "more_defaults", do: %{
    type: :boolean,
    alias: :m,
    defaults: [
      something: "else"
    ]
  }

  flag "dir", do: [
    type: :string
  ]
end
iex> MyArguments.parse(["--name", "myname"])
%{name: "myname", dir: "./myname"}

iex> MyArguments.parse(["new", "myname", "dirhere"])
%{new: true, name: "myname", dir: "dirhere"}

iex> MyArguments.parse(["--more"])
%{more: true}

iex> MyArguments.parse(["-m"])
%{more: true}

iex> MyArguments.parse(["--not-defined"])
%{}