2025-09-26 23:56:49 +00:00
|
|
|
use command_parser::token::TokensIterator;
|
2025-01-04 07:35:04 +09:00
|
|
|
|
2025-09-30 18:45:35 +00:00
|
|
|
use crate::utils::get_list_flags;
|
|
|
|
|
|
2025-09-26 23:56:49 +00:00
|
|
|
use super::*;
|
|
|
|
|
|
2025-09-30 18:45:35 +00:00
|
|
|
pub fn group() -> (&'static str, [&'static str; 2]) {
|
|
|
|
|
("group", ["g", "groups"])
|
2025-09-26 23:56:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn targeted() -> TokensIterator {
|
|
|
|
|
tokens!(group(), GroupRef)
|
|
|
|
|
}
|
2025-09-30 18:45:35 +00:00
|
|
|
|
|
|
|
|
pub fn cmds() -> impl Iterator<Item = Command> {
|
|
|
|
|
let group = group();
|
|
|
|
|
let group_target = targeted();
|
|
|
|
|
|
|
|
|
|
let apply_list_opts = |cmd: Command| cmd.flags(get_list_flags());
|
|
|
|
|
|
|
|
|
|
let group_list_members = tokens!(group_target, ("members", ["list", "ls"]));
|
|
|
|
|
let group_list_members_cmd = [
|
|
|
|
|
command!(group_list_members => "group_list_members"),
|
|
|
|
|
command!(group_list_members, "list" => "group_list_members"),
|
|
|
|
|
command!(group_list_members, ("search", ["find", "query"]), ("query", OpaqueStringRemainder) => "group_search_members"),
|
|
|
|
|
]
|
|
|
|
|
.into_iter()
|
|
|
|
|
.map(apply_list_opts);
|
|
|
|
|
|
|
|
|
|
let system_groups_cmd = [
|
|
|
|
|
command!(group, ("list", ["ls"]) => "group_list_groups"),
|
|
|
|
|
command!(group, ("search", ["find", "query"]), ("query", OpaqueStringRemainder) => "group_search_groups"),
|
|
|
|
|
]
|
|
|
|
|
.into_iter()
|
|
|
|
|
.map(apply_list_opts);
|
|
|
|
|
|
|
|
|
|
system_groups_cmd.chain(group_list_members_cmd)
|
|
|
|
|
}
|