mod plugin;
mod builtin_commands;
use anyhow::Result;
use plugin::PluginRegistry;
use builtin_commands::{HelpCommand, VersionCommand};
use std::env;
fn main() -> Result<()> {
let mut registry = PluginRegistry::new();
registry.register_command(Box::new(HelpCommand));
registry.register_command(Box::new(VersionCommand));
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
let help = registry.get_command("help").unwrap();
return help.execute(&[]);
}
let command_name = &args[1];
let command_args = &args[2..];
match registry.get_command(command_name) {
Some(command) => command.execute(command_args)?,
None => {
eprintln!("Unknown command: {}", command_name);
eprintln!("Run 'ff-cli help' for usage information");
std::process::exit(1);
}
}
Ok(())
}