feat(commands): add typed flags, misplaced and non-applicable flags error reporting

This commit is contained in:
dusk 2025-01-14 11:53:56 +09:00
parent 816aa68b33
commit 300539fdda
No known key found for this signature in database
8 changed files with 454 additions and 139 deletions

View file

@ -21,17 +21,17 @@ impl TreeBranch {
// iterate over tokens in command
for token in command.tokens.clone() {
// recursively get or create a sub-branch for each token
current_branch = current_branch.branches.entry(token).or_insert(TreeBranch {
current_command: None,
branches: OrderMap::new(),
});
current_branch = current_branch
.branches
.entry(token)
.or_insert_with(TreeBranch::empty);
}
// when we're out of tokens, add an Empty branch with the callback and no sub-branches
current_branch.branches.insert(
Token::Empty,
TreeBranch {
current_command: Some(command),
branches: OrderMap::new(),
current_command: Some(command),
},
);
}