# `Igniter.Mix.Task`
[🔗](https://github.com/ash-project/igniter/blob/v0.8.3/lib/mix/task.ex#L5)

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

> ### Note {: .info}
>
> A default `run/1` is implemented so you can directly run the task. Igniter never uses this function, so it is overridable.
>
> This enables your library to make use of the task for its own purposes if needed. An example would be if you wanted to implement an Igniter installer, but also have an `install` task for end-user consumption (e.g. `mix tailwind.install`).

## Options and Arguments

Command line args are automatically parsed into `igniter.args` using the configuration returned
from `c:info/2`. See `Igniter.Mix.Task.Info` for more.

# `igniter`
*optional* 

```elixir
@callback igniter(igniter :: Igniter.t()) :: Igniter.t()
```

Main entrypoint for tasks. This callback accepts and returns an `Igniter` struct.

# `igniter`
*optional* 

> This callback is deprecated. Use igniter/1 instead.

```elixir
@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.

# `info`

```elixir
@callback info(argv :: [String.t()], composing_task :: nil | String.t()) ::
  Igniter.Mix.Task.Info.t()
```

Returns an `Igniter.Mix.Task.Info` struct, with information used when running the igniter task.

This info will be used to validate arguments in composed tasks.

Use the `positional_args!(argv)` to get your positional arguments according to your `info.positional`, and the remaining unused args.
Use the `options!(argv)` macro to get your parsed options according to your `info.schema`.

## Important Limitations

* Each task still must parse its own argv in `igniter/2` and *must* ignore any unknown options.
  To accomplish this, use the automatically imported `options!(argv)` macro, which uses the `info/2`
  callback to validate args and return 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.

# `installer?`

```elixir
@callback installer?() :: boolean()
```

# `parse_argv`

```elixir
@callback parse_argv(argv :: [String.t()]) :: Igniter.Mix.Task.Args.t()
```

Returns an `Igniter.Mix.Task.Args` struct.

This callback can be implemented to private custom parsing and validation behavior for
command line arguments. By default, the options specified in `c:info/2` will be used
to inject a default implementation.

# `supports_umbrella?`

```elixir
@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.

# `options!`
*macro* 

> This macro is deprecated. use `igniter.args.options` instead.

```elixir
@spec options!(argv :: term()) :: term() | no_return()
```

Parses the options for the task based on its info.

# `positional_args!`
*macro* 

> This macro is deprecated. use `igniter.args.positional` instead.

# `set_yes`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
