View Source Igniter.Mix.Task behaviour (igniter v0.2.4)

A behaviour for implementing a Mix task that is enriched to be composable with other Igniter tasks.

Summary

Callbacks

All the generator behavior happens here, you take an igniter and task arguments, and return an igniter.

Returns an option schema and a list of tasks that this task might compose and pass all argv to.

Whether or not it supports being run in the root of an umbrella project

Callbacks

@callback igniter(igniter :: Igniter.t(), argv :: [String.t()]) :: Igniter.t()

All the generator behavior happens here, you take an igniter and task arguments, and return an igniter.

Link to this callback

option_schema(argv, source)

View Source
@callback option_schema(argv :: [String.t()], source :: nil | String.t()) ::
  %{
    optional(:schema) => Keyword.t(),
    optional(:aliases) => Keyword.t(),
    optional(:composes) => [String.t()]
  }
  | nil

Returns an option schema and a list of tasks that this task might compose and pass all argv to.

The option schema should be in the format you give to OptionParser.

This is callback is used to validate all options up front.

The following keys can be returned:

  • schema - The option schema for this task.
  • aliases - A map of aliases to the schema keys.
  • extra_args? - Whether or not to allow extra arguments. This forces all tasks that compose this task to allow extra args as well.
  • composes - A list of tasks that this task might compose.

Your task should always use switches and not strict to validate provided options!

Important Limitations

  • Each task still must parse its own argv in igniter/2 and must ignore any unknown options.
  • You cannot use composes to list tasks unless they are in your library or in direct dependencies of your library. To validate their options, you must include their options in your own option schema.
@callback supports_umbrella?() :: boolean()

Whether or not it supports being run in the root of an umbrella project

At the moment, this is still experimental and we suggest not turning it on.