View Source mix example (nexus v0.3.0)

This is a Mix Task example using Nexus. Basically, you can use both Mix.Task and Nexus modules, define your commands as usual with defcommand/2 and implement others callbacks.

Then you need to call Nexus.parse/0, that will inject both parse/1 and run/1 functions into your module. In a Mix.Task module, the run/1 function will supply the behaviour, so you don't need to define it yourself.

If you need to do other computations inside Mix.Task.run/1, then simply define run/1 by yourself and call __MODULE__.run/1 when you need it, passing the raw args to it.

Summary

Functions

Link to this function

parse(args \\ System.argv())

View Source
@spec parse([binary()]) :: {:ok, Nexus.CLI.t()} | {:error, atom()}

Callback implementation for Mix.Task.run/1.