Alaja.CLI.ErrorHandler (Alaja v2.2.0)

Copy Markdown View Source

Error handling for CLI commands.

Provides formatted error messages, suggestions, and appropriate exit codes.

Summary

Functions

Prints flag validation errors and exits.

Prints a formatted error message for the CLI.

Shows error for missing required positional arguments.

Shows error when no command is given.

Shows error when a command has no run handler.

Handles unknown command by showing suggestions.

Functions

flag_errors(errors)

@spec flag_errors([String.t()]) :: {:error, atom()}

Prints flag validation errors and exits.

format_error(title, detail)

@spec format_error(String.t(), String.t()) :: {:error, atom()}

Prints a formatted error message for the CLI.

missing_args(command_name, missing_names)

@spec missing_args(String.t(), [atom()]) :: {:error, atom()}

Shows error for missing required positional arguments.

no_command(commands)

@spec no_command([map()]) :: {:error, :no_command}

Shows error when no command is given.

no_handler(name)

@spec no_handler(String.t()) :: {:error, :no_handler}

Shows error when a command has no run handler.

unknown_command(command, commands)

@spec unknown_command(String.t(), [map()]) :: {:error, :unknown_command}

Handles unknown command by showing suggestions.