Minga.CLI (Minga v0.1.0)

Copy Markdown View Source

Command-line interface for Minga.

Serves as the entry point for both mix minga <filename> and the standalone Burrito binary (./minga <filename>). In Burrito mode, arguments are fetched via Burrito.Util.Args.argv/0 which works whether running standalone or under Mix.

Startup view

By default, Minga boots into the agentic view (controlled by the :startup_view config option). CLI flags can override the config:

  • --editor forces the traditional file editing view
  • File arguments open in the traditional file editing view by default
  • Directory arguments open the agentic view with the directory as context
  • --no-context opens the agentic view but skips loading the CLI file argument as preview context
  • --headless starts only the services and agent runtime, plus the JSON-RPC Gateway

Summary

Types

CLI flags that override config options.

Parsed CLI result.

Startup view mode requested by CLI flags.

Functions

Applies flag implications to a flags map.

Applies flag implications with file-aware startup view resolution.

Returns the project root inferred from the current CLI argv before startup flags are stored.

Returns the marked project root inferred from the current working directory, if any.

Returns true when args request headless mode.

Returns the output for info-only flags (--version/-v, --help/-h).

Main entry point for the CLI.

Returns true when args request minimal mode (for GIT_EDITOR use).

Parses CLI arguments into an action.

Returns true when args request safe mode.

Entry point used by the OTP application in release/Burrito mode.

Returns the startup flags stored by the CLI, or defaults if none were set.

Returns the project root inferred from the stored startup CLI target, if any.

Returns the project root inferred from raw CLI args, if they name a project or file inside a project.

Returns true when args request a terminal-only remote command.

Returns true when args request a terminal-only remote command after parsing flags.

Types

flags()

@type flags() :: %{
  view_mode: view_mode(),
  no_context: boolean(),
  config_file: String.t() | nil,
  debug_log: String.t() | nil,
  headless: boolean(),
  minimal: boolean(),
  safe_mode: boolean(),
  node_name: String.t() | nil,
  short_name: boolean(),
  cookie_file: String.t() | nil,
  gateway_port: pos_integer() | nil,
  gateway_host: String.t() | nil
}

CLI flags that override config options.

parsed()

@type parsed() ::
  {:open, file :: String.t() | nil, flags()}
  | {:attach, url :: String.t(), flags()}
  | {:sessions, url :: String.t(), flags()}
  | {:detach, flags()}
  | {:kill_session, url :: String.t(), flags()}
  | {:login, flags()}
  | {:error, String.t()}

Parsed CLI result.

view_mode()

@type view_mode() :: :auto | :editor | :agentic

Startup view mode requested by CLI flags.

Functions

apply_flag_implications(flags)

@spec apply_flag_implications(flags()) :: flags()

Applies flag implications to a flags map.

apply_flag_implications(flags, file)

@spec apply_flag_implications(flags(), String.t() | nil) :: flags()

Applies flag implications with file-aware startup view resolution.

argv_startup_project_root()

@spec argv_startup_project_root() :: String.t() | nil

Returns the project root inferred from the current CLI argv before startup flags are stored.

cwd_startup_project_root()

@spec cwd_startup_project_root() :: String.t() | nil

Returns the marked project root inferred from the current working directory, if any.

headless_args?(args)

@spec headless_args?([String.t()]) :: boolean()

Returns true when args request headless mode.

info_flag_output(args)

@spec info_flag_output([String.t()]) :: {:ok, String.t()} | :none

Returns the output for info-only flags (--version/-v, --help/-h).

These flags should print and exit without booting the supervision tree, so the application start path can short-circuit before doing any work. Returns :none when the args don't request info-only output.

main(args)

@spec main([String.t()]) :: :ok

Main entry point for the CLI.

minimal_args?(args)

@spec minimal_args?([String.t()]) :: boolean()

Returns true when args request minimal mode (for GIT_EDITOR use).

parse_args(args)

@spec parse_args([String.t()]) :: parsed()

Parses CLI arguments into an action.

safe_args?(args)

@spec safe_args?([String.t()]) :: boolean()

Returns true when args request safe mode.

start_from_cli()

@spec start_from_cli() :: :ok

Entry point used by the OTP application in release/Burrito mode.

startup_flags()

@spec startup_flags() :: flags()

Returns the startup flags stored by the CLI, or defaults if none were set.

startup_project_root()

@spec startup_project_root() :: String.t() | nil

Returns the project root inferred from the stored startup CLI target, if any.

startup_project_root_from_args(args)

@spec startup_project_root_from_args([String.t()]) :: String.t() | nil

Returns the project root inferred from raw CLI args, if they name a project or file inside a project.

terminal_command?(args)

@spec terminal_command?([String.t()]) :: boolean()

Returns true when args request a terminal-only remote command.

terminal_command_args?(args)

@spec terminal_command_args?([String.t()]) :: boolean()

Returns true when args request a terminal-only remote command after parsing flags.