Declarative DSL for defining CLI commands.
Usage
defmodule MyApp.CLI do
use Alaja.CLI.Definition, otp_app: :my_app
command "deploy", "Deploy to production" do
flag :env, :string, default: "staging", values: ~w(staging production)
flag :force, :boolean, default: false
run fn opts ->
IO.puts("Deploying to " <> opts.env)
if opts.force, do: IO.puts("Forced mode!")
end
end
subcommand "config", "Manage configuration" do
command "get", "Read a value" do
argument :key, :string, required: true
run fn opts -> IO.inspect(opts.key) end
end
end
endStructure
The DSL generates a command map with the following shape:
%{
name: "deploy",
description: "Deploy to production",
flags: [...],
arguments: [...],
subcommands: %{},
run: function
}
Summary
Functions
Defines a positional argument within a command.
Defines a CLI command with a name, description, and block.
Defines a CLI flag within a command.
Defines the handler function for a command.
Defines a CLI subcommand group.
Types
Functions
Defines a positional argument within a command.
Defines a CLI command with a name, description, and block.
Defines a CLI flag within a command.
Defines the handler function for a command.
Defines a CLI subcommand group.