Skip to content

Commit 1faea1e

Browse files
fix: update profile and context help (#874)
* fix: update profile and context help * fix: remove comments
1 parent 64df967 commit 1faea1e

File tree

3 files changed

+111
-36
lines changed

3 files changed

+111
-36
lines changed

crates/q_cli/src/cli/chat/command.rs

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,42 @@ pub enum ProfileSubcommand {
1919
Delete { name: String },
2020
Set { name: String },
2121
Rename { old_name: String, new_name: String },
22+
Help,
2223
}
2324

2425
impl ProfileSubcommand {
25-
const CREATE_USAGE: &str = "/profile create profile_name";
26-
const DELETE_USAGE: &str = "/profile delete profile_name";
27-
const RENAME_USAGE: &str = "/profile rename old_profile_name new_profile_name";
28-
const SET_USAGE: &str = "/profile set profile_name";
26+
const AVAILABLE_COMMANDS: &str = color_print::cstr! {"<cyan!>Available commands</cyan!>
27+
<em>help</em> <black!>Show an explanation for the profile command</black!>
28+
<em>list</em> <black!>List all available profiles</black!>
29+
<em>create <<name>></em> <black!>Create a new profile with the specified name</black!>
30+
<em>delete <<name>></em> <black!>Delete the specified profile</black!>
31+
<em>set <<name>></em> <black!>Switch to the specified profile</black!>
32+
<em>rename <<old>> <<new>></em> <black!>Rename a profile</black!>"};
33+
const CREATE_USAGE: &str = "/profile create <profile_name>";
34+
const DELETE_USAGE: &str = "/profile delete <profile_name>";
35+
const RENAME_USAGE: &str = "/profile rename <old_profile_name> <new_profile_name>";
36+
const SET_USAGE: &str = "/profile set <profile_name>";
2937

3038
fn usage_msg(header: impl AsRef<str>) -> String {
31-
format!(
32-
"{}\n\nUsage:\n {}\n {}\n {}\n {}",
33-
header.as_ref(),
34-
ProfileSubcommand::CREATE_USAGE,
35-
ProfileSubcommand::DELETE_USAGE,
36-
ProfileSubcommand::RENAME_USAGE,
37-
ProfileSubcommand::SET_USAGE
39+
format!("{}\n\n{}", header.as_ref(), Self::AVAILABLE_COMMANDS)
40+
}
41+
42+
pub fn help_text() -> String {
43+
color_print::cformat!(
44+
r#"
45+
<magenta,em>Profile Management</magenta,em>
46+
47+
Profiles allow you to organize and manage different sets of context files for different projects or tasks.
48+
49+
{}
50+
51+
<cyan!>Notes</cyan!>
52+
• The "global" profile contains context files that are available in all profiles
53+
• The "default" profile is used when no profile is specified
54+
• You can switch between profiles to work on different projects
55+
• Each profile maintains its own set of context files
56+
"#,
57+
Self::AVAILABLE_COMMANDS
3858
)
3959
}
4060
}
@@ -56,22 +76,51 @@ pub enum ContextSubcommand {
5676
Clear {
5777
global: bool,
5878
},
79+
Help,
5980
}
6081

6182
impl ContextSubcommand {
62-
const ADD_USAGE: &str = "/context add [--global] [--force] path1 [path2...]";
83+
const ADD_USAGE: &str = "/context add [--global] [--force] <path1> [path2...]";
84+
const AVAILABLE_COMMANDS: &str = color_print::cstr! {"<cyan!>Available commands</cyan!>
85+
<em>help</em> <black!>Show an explanation for the context command</black!>
86+
<em>show [--expand]</em> <black!>Display current context configuration</black!>
87+
<black!>Use --expand to list all matched files</black!>
88+
89+
<em>add [--global] [--force] <<paths...>></em>
90+
<black!>Add file(s) to context</black!>
91+
<black!>--global: Add to global context (available in all profiles)</black!>
92+
<black!>--force: Add files even if they exceed size limits</black!>
93+
94+
<em>rm [--global] <<paths...>></em> <black!>Remove file(s) from context</black!>
95+
<black!>--global: Remove from global context</black!>
96+
97+
<em>clear [--global]</em> <black!>Clear all files from current context</black!>
98+
<black!>--global: Clear global context</black!>"};
6399
const CLEAR_USAGE: &str = "/context clear [--global]";
64-
const REMOVE_USAGE: &str = "/context rm [--global] path1 [path2...]";
100+
const REMOVE_USAGE: &str = "/context rm [--global] <path1> [path2...]";
65101
const SHOW_USAGE: &str = "/context show [--expand]";
66102

67103
fn usage_msg(header: impl AsRef<str>) -> String {
68-
format!(
69-
"{}\n\nUsage:\n {}\n {}\n {}\n {}",
70-
header.as_ref(),
71-
ContextSubcommand::SHOW_USAGE,
72-
ContextSubcommand::ADD_USAGE,
73-
ContextSubcommand::REMOVE_USAGE,
74-
ContextSubcommand::CLEAR_USAGE
104+
format!("{}\n\n{}", header.as_ref(), Self::AVAILABLE_COMMANDS)
105+
}
106+
107+
pub fn help_text() -> String {
108+
color_print::cformat!(
109+
r#"
110+
<magenta,em>Context Management</magenta,em>
111+
112+
Context files provide Amazon Q with additional information about your project or environment.
113+
Adding relevant files to your context helps Amazon Q provide more accurate and helpful responses.
114+
115+
{}
116+
117+
<cyan!>Notes</cyan!>
118+
• You can add specific files or use glob patterns (e.g., "*.py", "src/**/*.js")
119+
• Context files are associated with the current profile
120+
• Global context files are available across all profiles
121+
• Context is preserved between chat sessions
122+
"#,
123+
Self::AVAILABLE_COMMANDS
75124
)
76125
}
77126
}
@@ -100,7 +149,7 @@ impl Command {
100149
macro_rules! usage_err {
101150
($usage_str:expr) => {
102151
return Err(format!(
103-
"Invalid /profile arguments.\n\nUsage:\n {}",
152+
"Invalid /profile arguments.\n\nUsage:\n {}",
104153
$usage_str
105154
))
106155
};
@@ -156,6 +205,9 @@ impl Command {
156205
None => usage_err!(ProfileSubcommand::SET_USAGE),
157206
}
158207
},
208+
"help" => Self::Profile {
209+
subcommand: ProfileSubcommand::Help,
210+
},
159211
other => {
160212
return Err(ProfileSubcommand::usage_msg(format!("Unknown subcommand '{}'.", other)));
161213
},
@@ -169,7 +221,7 @@ impl Command {
169221
macro_rules! usage_err {
170222
($usage_str:expr) => {
171223
return Err(format!(
172-
"Invalid /context arguments.\n\nUsage:\n {}",
224+
"Invalid /context arguments.\n\nUsage:\n {}",
173225
$usage_str
174226
))
175227
};
@@ -253,6 +305,9 @@ impl Command {
253305
subcommand: ContextSubcommand::Clear { global },
254306
}
255307
},
308+
"help" => Self::Context {
309+
subcommand: ContextSubcommand::Help,
310+
},
256311
other => {
257312
return Err(ContextSubcommand::usage_msg(format!("Unknown subcommand '{}'.", other)));
258313
},

crates/q_cli/src/cli/chat/mod.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ const WELCOME_TEXT: &str = color_print::cstr! {"
9595
• Help me understand my git status
9696
9797
<em>/acceptall</em> <black!>Toggles acceptance prompting for the session.</black!>
98-
<em>/context</em> <black!>Manage context files for the chat session</black!>
98+
<em>/profile</em> <black!>Manage profiles for the chat session</black!>
99+
<em>/context</em> <black!>Manage context files for a profile</black!>
99100
<em>/help</em> <black!>Show the help dialogue</black!>
100101
<em>/quit</em> <black!>Quit the application</black!>
101102
@@ -110,13 +111,15 @@ const HELP_TEXT: &str = color_print::cstr! {"
110111
<em>/acceptall</em> <black!>Toggles acceptance prompting for the session.</black!>
111112
<em>/help</em> <black!>Show this help dialogue</black!>
112113
<em>/quit</em> <black!>Quit the application</black!>
113-
<em>/profile</em> <black!>Manage context profiles</black!>
114-
<em>list</em> <black!>List context profiles</black!>
115-
<em>create</em> <black!>Create a new context profile</black!>
116-
<em>delete</em> <black!>Delete a context profile</black!>
117-
<em>rename</em> <black!>Rename a context profile</black!>
118-
<em>set</em> <black!>Set the current context profile</black!>
114+
<em>/profile</em> <black!>Manage profiles</black!>
115+
<em>help</em> <black!>Show profile help</black!>
116+
<em>list</em> <black!>List profiles</black!>
117+
<em>set</em> <black!>Set the current profile</black!>
118+
<em>create</em> <black!>Create a new profile</black!>
119+
<em>delete</em> <black!>Delete a profile</black!>
120+
<em>rename</em> <black!>Rename a profile</black!>
119121
<em>/context</em> <black!>Manage context files for the chat session</black!>
122+
<em>help</em> <black!>Show context help</black!>
120123
<em>show</em> <black!>Display current context configuration [--expand]</black!>
121124
<em>add</em> <black!>Add file(s) to context [--global] [--force]</black!>
122125
<em>rm</em> <black!>Remove file(s) from context [--global]</black!>
@@ -752,6 +755,14 @@ where
752755
Err(e) => print_err!(e),
753756
}
754757
},
758+
command::ProfileSubcommand::Help => {
759+
execute!(
760+
self.output,
761+
style::Print("\n"),
762+
style::Print(command::ProfileSubcommand::help_text()),
763+
style::Print("\n")
764+
)?;
765+
},
755766
}
756767
}
757768
ChatState::PromptUser {
@@ -912,6 +923,14 @@ where
912923
)?;
913924
},
914925
},
926+
command::ContextSubcommand::Help => {
927+
execute!(
928+
self.output,
929+
style::Print("\n"),
930+
style::Print(command::ContextSubcommand::help_text()),
931+
style::Print("\n")
932+
)?;
933+
},
915934
}
916935
// fig_telemetry::send_context_command_executed
917936
} else {

crates/q_cli/src/cli/chat/prompt.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,20 @@ const COMMANDS: &[&str] = &[
3131
"/acceptall",
3232
"/quit",
3333
"/profile",
34-
"/context",
34+
"/profile help",
35+
"/profile list",
36+
"/profile add",
37+
"/profile create",
38+
"/profile delete",
39+
"/profile rename",
40+
"/profile set",
41+
"/context help",
3542
"/context show",
3643
"/context show --expand",
3744
"/context add",
3845
"/context add --global",
3946
"/context rm",
4047
"/context rm --global",
41-
"/context profile",
42-
"/context profile --create",
43-
"/context profile --delete",
44-
"/context profile --rename",
45-
"/context switch",
46-
"/context switch --create",
4748
"/context clear",
4849
"/context clear --global",
4950
];

0 commit comments

Comments
 (0)