View Source DoIt.Introspection (do_it v0.7.0)

Provides introspection capabilities for DoIt commands and their structure.

This module enables analysis of command hierarchies, options, arguments, and other metadata needed for features like auto-completion.

Summary

Functions

Finds a command module by name from a MainCommand module.

Finds a subcommand module by name from a Command module.

Gets all possible command paths as flat list.

Gets all top-level commands from a MainCommand module.

Gets all arguments from a Command module.

Gets all option flags (--name and -alias) from a Command module.

Gets all options from a Command module.

Gets the command structure as a nested map for introspection.

Gets all subcommands from a Command module.

Checks if a command has subcommands.

Resolves a command path to its final command module.

Functions

Link to this function

find_command_module(main_module, command_name)

View Source

Finds a command module by name from a MainCommand module.

Returns the module atom or nil if not found.

Link to this function

find_subcommand_module(command_module, subcommand_name)

View Source

Finds a subcommand module by name from a Command module.

Returns the module atom or nil if not found.

Link to this function

get_all_command_paths(main_module)

View Source

Gets all possible command paths as flat list.

Returns a list of command paths where each path is a list of strings.

Link to this function

get_all_commands(main_module)

View Source

Gets all top-level commands from a MainCommand module.

Returns a list of command names as strings.

Link to this function

get_command_arguments(command_module)

View Source

Gets all arguments from a Command module.

Returns a list of DoIt.Argument structs.

Link to this function

get_command_option_flags(command_module)

View Source

Gets all option flags (--name and -alias) from a Command module.

Returns a list of option flags as strings.

Link to this function

get_command_options(command_module)

View Source

Gets all options from a Command module.

Returns a list of DoIt.Option structs.

Link to this function

get_command_structure(main_module)

View Source

Gets the command structure as a nested map for introspection.

Returns a map containing the full command hierarchy with metadata.

Link to this function

get_subcommands(command_module)

View Source

Gets all subcommands from a Command module.

Returns a list of subcommand names as strings.

Link to this function

has_subcommands?(command_module)

View Source

Checks if a command has subcommands.

Link to this function

resolve_command_path(main_module, list)

View Source

Resolves a command path to its final command module.

Takes a main module and a list of command/subcommand names, returns the final command module or nil if path is invalid.

Examples

iex> resolve_command_path(MyApp, ["user", "create"])
MyApp.User.Create

iex> resolve_command_path(MyApp, ["invalid"])
nil