Skip to content

Commit 0e431c2

Browse files
Revert "Revert "feat(agent): adds root command for chat's agent root command (#431)" (#443)" (#492)
This reverts commit 4572eec.
1 parent 2341057 commit 0e431c2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/q_cli/src/cli/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ pub enum CliRootCommands {
218218
/// Inline shell completions
219219
#[command(subcommand)]
220220
Inline(inline::InlineSubcommand),
221+
/// Agent root commands
222+
#[command(disable_help_flag = true)]
223+
Agent {
224+
/// Args for Agent subcommand
225+
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
226+
args: Vec<String>,
227+
},
221228
}
222229

223230
impl CliRootCommands {
@@ -252,6 +259,7 @@ impl CliRootCommands {
252259
CliRootCommands::Chat { .. } => "chat",
253260
CliRootCommands::Mcp { .. } => "mcp",
254261
CliRootCommands::Inline(_) => "inline",
262+
CliRootCommands::Agent { .. } => "agent",
255263
}
256264
}
257265
}
@@ -375,6 +383,13 @@ impl Cli {
375383
Self::execute_chat("mcp", Some(args), true).await
376384
},
377385
CliRootCommands::Inline(subcommand) => subcommand.execute(&cli_context).await,
386+
CliRootCommands::Agent { args } => {
387+
if args.iter().any(|arg| ["--help", "-h"].contains(&arg.as_str())) {
388+
return Self::execute_chat("agent", Some(args), false).await;
389+
}
390+
391+
Self::execute_chat("agent", Some(args), true).await
392+
},
378393
},
379394
// Root command
380395
None => Self::execute_chat("chat", None, true).await,

0 commit comments

Comments
 (0)