ComposerNew.Argv (composer_new v0.3.0)

Copy Markdown View Source

Splits mix composer.new argv into APP, REF, the archive's own options and the recipe flags.

This is a manual pass, like igniter.new's, rather than OptionParser in :strict mode: a strict parse drops the switches it doesn't know, which are the recipe flags here, and would read the --no-ecto of --with-args --no-ecto as a switch. The rules:

  • APP is the first argument
  • an option with a value takes --opt=value or --opt value; for --with-args, the separate form takes the next argument as it is, even when it starts with -
  • --install and --extra-dep repeat, and --install also splits on ,
  • --reset, --dry-run and --no-recipe are booleans
  • any other -x or --x is a recipe flag, kept in order
  • after --, everything is a recipe flag
  • the second positional argument is REF, and a third is an error

Summary

Functions

Parses argv.

Types

t()

@type t() :: %{
  app: String.t(),
  ref: String.t() | nil,
  opts: keyword(),
  recipe_flags: [String.t()]
}

Functions

parse(list)

@spec parse([String.t()]) :: {:ok, t()} | {:error, String.t()}

Parses argv.