Skip to content

Commit defff47

Browse files
authored
fix: improve tool trust/untrust usage messages for better clarity (#1400)
1 parent 6f11d02 commit defff47

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

crates/q_chat/src/command.rs

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ impl ToolsSubcommand {
306306
Show the current set of tools and their permission setting.
307307
The permission setting states when user confirmation is required. Trusted tools never require confirmation.
308308
Alternatively, specify a subcommand to modify the tool permissions."};
309-
const TRUST_USAGE: &str = "/tools trust <tools...>";
310-
const UNTRUST_USAGE: &str = "/tools untrust <tools...>";
311309

312310
fn usage_msg(header: impl AsRef<str>) -> String {
313311
format!(
@@ -695,15 +693,6 @@ impl Command {
695693
return Ok(Self::Tools { subcommand: None });
696694
}
697695

698-
macro_rules! usage_err {
699-
($subcommand:expr, $usage_str:expr) => {
700-
return Err(format!(
701-
"Invalid /tools {} arguments.\n\nUsage:\n {}",
702-
$subcommand, $usage_str
703-
))
704-
};
705-
}
706-
707696
match parts[1].to_lowercase().as_str() {
708697
"schema" => Self::Tools {
709698
subcommand: Some(ToolsSubcommand::Schema),
@@ -715,7 +704,21 @@ impl Command {
715704
}
716705

717706
if tool_names.is_empty() {
718-
usage_err!("trust", ToolsSubcommand::TRUST_USAGE);
707+
let _ = queue!(
708+
output,
709+
style::SetForegroundColor(Color::DarkGrey),
710+
style::Print("\nPlease use"),
711+
style::SetForegroundColor(Color::DarkGreen),
712+
style::Print(" /tools trust <tool1> <tool2>"),
713+
style::SetForegroundColor(Color::DarkGrey),
714+
style::Print(" to trust tools.\n\n"),
715+
style::Print("Use "),
716+
style::SetForegroundColor(Color::DarkGreen),
717+
style::Print("/tools"),
718+
style::SetForegroundColor(Color::DarkGrey),
719+
style::Print(" to see all available tools.\n\n"),
720+
style::SetForegroundColor(Color::Reset),
721+
);
719722
}
720723

721724
Self::Tools {
@@ -729,7 +732,21 @@ impl Command {
729732
}
730733

731734
if tool_names.is_empty() {
732-
usage_err!("untrust", ToolsSubcommand::UNTRUST_USAGE);
735+
let _ = queue!(
736+
output,
737+
style::SetForegroundColor(Color::DarkGrey),
738+
style::Print("\nPlease use"),
739+
style::SetForegroundColor(Color::DarkGreen),
740+
style::Print(" /tools untrust <tool1> <tool2>"),
741+
style::SetForegroundColor(Color::DarkGrey),
742+
style::Print(" to untrust tools.\n\n"),
743+
style::Print("Use "),
744+
style::SetForegroundColor(Color::DarkGreen),
745+
style::Print("/tools"),
746+
style::SetForegroundColor(Color::DarkGrey),
747+
style::Print(" to see all available tools.\n\n"),
748+
style::SetForegroundColor(Color::Reset),
749+
);
733750
}
734751

735752
Self::Tools {

0 commit comments

Comments
 (0)