CLI argument assembly and parsing.
Plugins enrich a shared %{options:, flags:, subcommands:} map through
the Marea.Plugins.Base.marea_config_args/1 chain (using add_options/2,
add_flags/2, add_subcommands/2). build_optimus/1 then turns the final map into
an Optimus parser, propagating any options/flags marked global: true
down to every leaf subcommand.
This module also exposes a small set of reusable option specs
(deploy_option/0, release_option/0, cookie_option/0,
pos_option/0, mix_env_option/1) used across the built-in plugins.
Summary
Types
Args config map enriched by the Marea.Plugins.Base.marea_config_args/1 plugin chain.
An {name, opts} Optimus option/flag/subcommand spec.
Functions
Appends new_flags to the args config. Use from Marea.Plugins.Base.marea_config_args/1.
Appends new_options to the args config. Use from Marea.Plugins.Base.marea_config_args/1.
Adds new_subcommands to the args config. Use from
Marea.Plugins.Base.marea_config_args/1.
Returns the base args config map that plugins enrich via Marea.Plugins.Base.marea_config_args/1.
Runs the Marea.Plugins.Base.marea_config_args/1 chain on a list of
plugin modules, returning the accumulated args map.
Builds an Optimus parser from the final (plugin-enriched) args config.
Reusable spec for the --cookie option (defaults to marea_cookie).
Reusable spec for the --deploy / -d option.
Reusable spec for --mix-env. If default is given, it is used when the option is missing.
Parses args against optimus, returning {cmds, options, flags}.
Reusable spec for --pos (integer; used to run multiple instances side-by-side).
Reusable spec for the --release / -r option.
Types
Functions
Appends new_flags to the args config. Use from Marea.Plugins.Base.marea_config_args/1.
Appends new_options to the args config. Use from Marea.Plugins.Base.marea_config_args/1.
Adds new_subcommands to the args config. Use from
Marea.Plugins.Base.marea_config_args/1.
Merges by key so multiple plugins can extend the same parent
subcommand (e.g. Marea.Plugins.Docker and Marea.Plugins.Helm both
contribute children under build). For an already-present parent,
the new entry's :subcommands / :options / :flags are appended,
and other keys (:name, :about, …) keep the first writer's value.
Top-level entries that don't yet exist are appended at the end.
@spec base_args() :: args()
Returns the base args config map that plugins enrich via Marea.Plugins.Base.marea_config_args/1.
Includes the global --marea-dir, --state-dir, --help, --nopause
options/flags, and an empty subcommands list.
Runs the Marea.Plugins.Base.marea_config_args/1 chain on a list of
plugin modules, returning the accumulated args map.
Unlike Malla.local/3, this does not require a running
Malla.Service: every plugin's marea_config_args/1 is a plain
function generated by defcb, so we can fold over them directly.
Used by the MCP server to expose tool descriptors without spinning
up the full service.
All marea_config_args/1 implementations are expected to return
{:cont, [args]}; any other shape is ignored (matching the default
in Marea.Plugins.Base).
Builds an Optimus parser from the final (plugin-enriched) args config.
@spec cookie_option() :: spec()
Reusable spec for the --cookie option (defaults to marea_cookie).
@spec deploy_option() :: spec()
Reusable spec for the --deploy / -d option.
Reusable spec for --mix-env. If default is given, it is used when the option is missing.
Parses args against optimus, returning {cmds, options, flags}.
Normalizes --help/-h placement so that marea aws --help becomes
marea help aws, and aborts with a clear error on unknown options or
parse failures.
@spec pos_option() :: spec()
Reusable spec for --pos (integer; used to run multiple instances side-by-side).
@spec release_option() :: spec()
Reusable spec for the --release / -r option.