Skip to content

Commit 520be85

Browse files
authored
refactor(context): Simplify 'show' command by removing --expand option (#1126)
1 parent 4307d77 commit 520be85

File tree

3 files changed

+10
-42
lines changed

3 files changed

+10
-42
lines changed

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

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ Profiles allow you to organize and manage different sets of context files for di
7070

7171
#[derive(Debug, Clone, PartialEq, Eq)]
7272
pub enum ContextSubcommand {
73-
Show {
74-
expand: bool,
75-
},
73+
Show,
7674
Add {
7775
global: bool,
7876
force: bool,
@@ -92,8 +90,8 @@ impl ContextSubcommand {
9290
const ADD_USAGE: &str = "/context add [--global] [--force] <path1> [path2...]";
9391
const AVAILABLE_COMMANDS: &str = color_print::cstr! {"<cyan!>Available commands</cyan!>
9492
<em>help</em> <black!>Show an explanation for the context command</black!>
95-
<em>show [--expand]</em> <black!>Display current context configuration</black!>
96-
<black!>Use --expand to list all matched files</black!>
93+
94+
<em>show</em> <black!>Display current context configuration</black!>
9795
9896
<em>add [--global] [--force] <<paths...>></em>
9997
<black!>Add file(s) to context</black!>
@@ -107,7 +105,6 @@ impl ContextSubcommand {
107105
<black!>--global: Clear global context</black!>"};
108106
const CLEAR_USAGE: &str = "/context clear [--global]";
109107
const REMOVE_USAGE: &str = "/context rm [--global] <path1> [path2...]";
110-
const SHOW_USAGE: &str = "/context show [--expand]";
111108

112109
fn usage_msg(header: impl AsRef<str>) -> String {
113110
format!("{}\n\n{}", header.as_ref(), Self::AVAILABLE_COMMANDS)
@@ -339,21 +336,8 @@ impl Command {
339336
}
340337

341338
match parts[1].to_lowercase().as_str() {
342-
"show" => {
343-
// Parse show command with optional --expand flag
344-
let mut expand = false;
345-
346-
for part in &parts[2..] {
347-
if *part == "--expand" {
348-
expand = true;
349-
} else {
350-
usage_err!(ContextSubcommand::SHOW_USAGE);
351-
}
352-
}
353-
354-
Self::Context {
355-
subcommand: ContextSubcommand::Show { expand },
356-
}
339+
"show" => Self::Context {
340+
subcommand: ContextSubcommand::Show,
357341
},
358342
"add" => {
359343
// Parse add command with paths and flags
@@ -544,11 +528,7 @@ mod tests {
544528
"/profile set p",
545529
profile!(ProfileSubcommand::Set { name: "p".to_string() }),
546530
),
547-
("/context show", context!(ContextSubcommand::Show { expand: false })),
548-
(
549-
"/context show --expand",
550-
context!(ContextSubcommand::Show { expand: true }),
551-
),
531+
("/context show", context!(ContextSubcommand::Show)),
552532
(
553533
"/context add p1 p2",
554534
context!(ContextSubcommand::Add {

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const HELP_TEXT: &str = color_print::cstr! {"
148148
<em>rename</em> <black!>Rename a profile</black!>
149149
<em>/context</em> <black!>Manage context files for the chat session</black!>
150150
<em>help</em> <black!>Show context help</black!>
151-
<em>show</em> <black!>Display current context configuration [--expand]</black!>
151+
<em>show</em> <black!>Display current context configuration</black!>
152152
<em>add</em> <black!>Add file(s) to context [--global] [--force]</black!>
153153
<em>rm</em> <black!>Remove file(s) from context [--global]</black!>
154154
<em>clear</em> <black!>Clear all files from current context [--global]</black!>
@@ -1007,7 +1007,7 @@ where
10071007
Command::Context { subcommand } => {
10081008
if let Some(context_manager) = &mut self.conversation_state.context_manager {
10091009
match subcommand {
1010-
command::ContextSubcommand::Show { expand } => {
1010+
command::ContextSubcommand::Show => {
10111011
execute!(
10121012
self.output,
10131013
style::SetForegroundColor(Color::Green),
@@ -1057,30 +1057,19 @@ where
10571057
style::Print("No files matched the configured context paths.\n\n"),
10581058
style::SetForegroundColor(Color::Reset)
10591059
)?;
1060-
} else if expand {
1060+
} else {
10611061
// Show expanded file list when expand flag is set
10621062
execute!(
10631063
self.output,
10641064
style::SetForegroundColor(Color::Green),
1065-
style::Print(format!("Expanded files ({}):\n", context_files.len())),
1065+
style::Print(format!("Files in use ({}):\n", context_files.len())),
10661066
style::SetForegroundColor(Color::Reset)
10671067
)?;
10681068

10691069
for (filename, _) in context_files {
10701070
execute!(self.output, style::Print(format!(" {}\n", filename)))?;
10711071
}
10721072
execute!(self.output, style::Print("\n"))?;
1073-
} else {
1074-
// Just show the count when expand flag is not set
1075-
execute!(
1076-
self.output,
1077-
style::SetForegroundColor(Color::Green),
1078-
style::Print(format!(
1079-
"Number of context files in use: {}\n",
1080-
context_files.len()
1081-
)),
1082-
style::SetForegroundColor(Color::Reset)
1083-
)?;
10841073
}
10851074
},
10861075
Err(e) => {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const COMMANDS: &[&str] = &[
5757
"/profile set",
5858
"/context help",
5959
"/context show",
60-
"/context show --expand",
6160
"/context add",
6261
"/context add --global",
6362
"/context rm",

0 commit comments

Comments
 (0)