bijux_cli/routing/
catalog.rs1#![forbid(unsafe_code)]
2fn contains(values: &[&str], value: &str) -> bool {
5 values.contains(&value)
6}
7
8#[must_use]
10pub fn cli_root_aliases() -> &'static [&'static str] {
11 super::model::CLI_ROOT_ALIASES
12}
13
14#[must_use]
16pub fn cli_config_subcommands() -> &'static [&'static str] {
17 super::model::CLI_CONFIG_SUBCOMMANDS
18}
19
20#[must_use]
22pub fn cli_plugins_subcommands() -> &'static [&'static str] {
23 super::model::CLI_PLUGINS_SUBCOMMANDS
24}
25
26#[must_use]
28pub fn normalize_command_path(path: &[String]) -> Vec<String> {
29 match path {
30 [a] if contains(super::model::CLI_ROOT_ALIASES, a) => vec!["cli".to_string(), a.clone()],
31 [a, b] if a == "config" && contains(super::model::CLI_CONFIG_SUBCOMMANDS, b) => {
32 vec!["cli".to_string(), "config".to_string(), b.clone()]
33 }
34 [a, b] if a == "plugins" && contains(super::model::CLI_PLUGINS_SUBCOMMANDS, b) => {
35 vec!["cli".to_string(), "plugins".to_string(), b.clone()]
36 }
37 _ => path.to_vec(),
38 }
39}
40
41#[must_use]
43pub fn is_known_route(path: &[String]) -> bool {
44 super::model::is_known_route(path)
45}
46
47#[must_use]
49pub fn repl_reference_commands() -> &'static [&'static str] {
50 super::model::REPL_REFERENCE_COMMANDS
51}