abstract class AzuCLI::Commands::Base

Overview

Base command class for all Azu CLI commands

Direct Known Subclasses

Defined in:

azu_cli/commands/base.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String, description : String = "") #

[View source]

Instance Method Detail

def all_args : Array(String) #

[View source]
def all_args=(all_args : Array(String)) #

[View source]
def args : Array(String) #

[View source]
def args=(args : Array(String)) #

[View source]
def description : String #

[View source]
def description=(description : String) #

[View source]
def error(message : String, category : String) : Result #

Error result with category


[View source]
def error(message : String) : Result #

Error result


[View source]
abstract def execute : Result #

Abstract method that all commands must implement


[View source]
def fatal_error(message : String, category : String = Config::ErrorCategory::UNKNOWN) : NoReturn #

Handle fatal error (always exits)


[View source]
def filesystem_error(message : String, category : String = Config::ErrorCategory::IO_ERROR) : Result #

Handle file system error


[View source]
def get_arg(index : Int32) : String | Nil #

Get argument at index


[View source]
def get_args : Array(String) #

Get all arguments (including flags)


[View source]
def get_option(key : String, default : String = "") : String #

Get option value with default


[View source]
def handle_error(message : String, category : String = Config::ErrorCategory::UNKNOWN, severity : Int32 = Config::ErrorSeverity::ERROR, exit_code : Int32 = Config::EXIT_FAILURE, should_exit : Bool = false) : Result #

Handle error with proper logging and optional exit


[View source]
def has_option?(key : String) : Bool #

Check if option is set


[View source]
def name : String #

[View source]
def name=(name : String) #

[View source]
def options : Hash(String, String) #

[View source]
def options=(options : Hash(String, String)) #

[View source]
def parse_args(args : Array(String)) #

Parse command line arguments using Crystal's OptionParser


[View source]
def show_examples #

Show command examples - can be overridden by subclasses


[View source]
def show_help #

Show help for this command


[View source]
def success(message : String = "") : Result #

Success result


[View source]
def validate_required_args(required_count : Int32) : Bool #

Validate required arguments


[View source]
def validate_required_options(required_options : Array(String)) : Bool #

Validate required options


[View source]
def validation_error(message : String) : Result #

Handle validation error with proper context


[View source]
def warning(message : String, category : String = Config::ErrorCategory::UNKNOWN) #

Handle warning (logs but doesn't fail)


[View source]
def with_error_handling(category : String = Config::ErrorCategory::RUNTIME_ERROR, &) #

Wrap exception handling with consistent error reporting


[View source]