13 namespace fs = std::filesystem;
27 using MaCh3ArgumentParser::MaCh3ArgumentParser;
48 void completions(
const std::string& prefix,
const std::vector<std::string>& context)
const;
66 bool write_file(
const fs::path& path, std::string_view content)
const;
80 local cur prev words cword
81 _init_completion || return
83 # Pass current prefix + preceding words as context; binary filters by prefix
85 mapfile -t raw < <(mach3 --complete "$cur" "${words[@]:1:$((cword-1))}" 2>/dev/null)
87 if [[ ${#raw[@]} -eq 0 ]]; then
88 # No completions from binary — fall back to default (file) completion
89 compopt -o default 2>/dev/null
92 COMPREPLY=( "${raw[@]}" )
94 complete -F _mach3_complete mach3
100 local cur="${words[$CURRENT]}"
102 ctx=("${words[@]:1:$((CURRENT-2))}")
105 completions=("${(@f)$(mach3 --complete "$cur" "${ctx[@]}" 2>/dev/null)}")
107 if [[ ${#completions[@]} -eq 0 ]]; then
111 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.
virtual ~MaCh3Program()
Destructor that unloads all dynamic plugins.
void unload_dynamic_plugins()
Unload all dynamically loaded plugins.
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
std::vector< std::string > m_subcommands
List of registered subcommand names.
void completions(const std::string &prefix, const std::vector< std::string > &context) const
Generate completion suggestions given the current prefix and preceding words.
void install_completions() const
Install shell completion scripts for bash and zsh.
static constexpr std::string_view BASH_COMPLETION
int Run()
Run the selected subcommand.
std::map< const MaCh3ArgumentParser *, IModule * > m_module_map
Map of parsers to core modules (non-owning)
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 .so files.
Main namespace for MaCh3 software.
Plugin interface and registration macros for MaCh3.