use crate::actions::ActionInvocation;
use super::{CommandSpec, command_specs};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct CommandLoader;
pub use super::{CommandParseError, load_command_invocation};
impl CommandLoader {
pub const fn new() -> Self {
Self
}
pub fn specs(&self) -> &'static [CommandSpec] {
command_specs()
}
pub fn load<I, S>(&self, args: I) -> Result<ActionInvocation, CommandParseError>
where
I: IntoIterator<Item = S>,
S: AsRef<str>,
{
load_command_invocation(args)
}
pub fn invalid_command_message(command: &str) -> String {
format!(
"\nError Invalid command: {command}\nSee --help for a list of available commands.\n"
)
}
}