14 namespace fs = std::filesystem;
28 using MaCh3ArgumentParser::MaCh3ArgumentParser;
29 using MaCh3ArgumentParser::parse_args;
32 void parse_args(
int argc,
const char *
const argv[]);
51 void completions(
const std::string& prefix,
const std::vector<std::string>& context)
const;
68 bool write_file(
const fs::path& path, std::string_view content)
const;
82 local cur prev words cword
83 _init_completion || return
85 # Pass current prefix + preceding words as context; binary filters by prefix
87 mapfile -t raw < <(mach3 --complete "$cur" "${words[@]:1:$((cword-1))}" 2>/dev/null)
89 if [[ ${#raw[@]} -eq 0 ]]; then
90 # No completions from binary — fall back to default (file) completion
91 compopt -o default 2>/dev/null
94 COMPREPLY=( "${raw[@]}" )
96 complete -F _mach3_complete mach3
102 local cur="${words[$CURRENT]}"
104 ctx=("${words[@]:1:$((CURRENT-2))}")
107 completions=("${(@f)$(mach3 --complete "$cur" "${ctx[@]}" 2>/dev/null)}")
109 if [[ ${#completions[@]} -eq 0 ]]; then
113 compadd -a completions
Wrapper class for dynamically loaded plugins.
Interface for MaCh3 plugins and modules.
Extended ArgumentParser with MaCh3-specific functionality.
Main program class that manages modules, plugins, and command-line parsing.
void add_core_module(IModule &module)
Add a core module to the program.
bool write_file(const fs::path &path, std::string_view content) const
Write content to a file, creating parent directories if needed.
static constexpr std::string_view ZSH_COMPLETION
void completions(const std::string &prefix, const std::vector< std::string > &context) const
Generate subcommand or long-option suggestions at the active parser depth.
static constexpr std::string_view BASH_COMPLETION
int install_completions() const
Install shell completion scripts for bash and zsh.
int Run()
Run the selected subcommand.
std::map< const MaCh3ArgumentParser *, IModule * > m_module_map
Map of parsers to core modules (non-owning)
std::set< std::string > m_attempted_plugin_paths
virtual ~MaCh3Program()=default
Destructor that unloads all dynamic plugins Fix plugin lifetime: shutdown-only unloading keeps borrow...
std::map< const MaCh3ArgumentParser *, std::unique_ptr< DynamicPlugin > > m_dynamic_plugin_map
Map of parsers to dynamic plugins (owning)
std::string detect_shell() const
Detect the user's shell from the SHELL environment variable.
void load_dynamic_plugins()
Load dynamic plugins from the MACH3_PLUGINS environment variable.
std::vector< std::string > expand_plugin_path(const std::string &path) const
Expand a plugin path (file or directory) into a list of canonical shared-library paths.
void validate_parser(const MaCh3ArgumentParser *parser) const
void parse_args(int argc, const char *const argv[])
Parse args after inserting any default subcommands.
Main namespace for MaCh3 software.
Plugin interface and registration macros for MaCh3.