Skip to content

Commit ff206a3

Browse files
committed
add chat execute
1 parent 03e4d9a commit ff206a3

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//! CLI functionality
2-
31
mod chat;
42
mod debug;
53
mod diagnostics;
@@ -198,7 +196,7 @@ impl Cli {
198196
self.send_telemetry().await;
199197

200198
if self.help_all {
201-
return self.print_help_all();
199+
return Self::print_help_all();
202200
}
203201

204202
let cli_context = CliContext::new();
@@ -229,8 +227,7 @@ impl Cli {
229227
}
230228
}
231229

232-
#[allow(clippy::unused_self)]
233-
fn print_help_all(&self) -> Result<ExitCode> {
230+
fn print_help_all() -> Result<ExitCode> {
234231
let mut cmd = Self::command().help_template("{all-args}");
235232
eprintln!();
236233
eprintln!(
@@ -263,7 +260,6 @@ impl Cli {
263260
Ok(())
264261
}
265262

266-
#[allow(clippy::unused_self)]
267263
fn print_version(changelog: Option<String>) -> Result<ExitCode> {
268264
// If no changelog is requested, display normal version information
269265
if changelog.is_none() {

crates/chat-cli/src/fig_util/system_info/linux.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#[cfg(target_os = "linux")]
12
use std::io;
3+
#[cfg(target_os = "linux")]
24
use std::path::Path;
3-
use std::sync::OnceLock;
45

56
use serde::{
67
Deserialize,
@@ -21,6 +22,7 @@ pub enum DesktopEnvironment {
2122
Sway,
2223
}
2324

25+
#[cfg(target_os = "linux")]
2426
pub fn get_os_release() -> Option<&'static OsRelease> {
2527
static OS_RELEASE: OnceLock<Option<OsRelease>> = OnceLock::new();
2628
OS_RELEASE.get_or_init(|| OsRelease::load().ok()).as_ref()
@@ -43,6 +45,7 @@ pub struct OsRelease {
4345
pub variant: Option<String>,
4446
}
4547

48+
#[cfg(target_os = "linux")]
4649
impl OsRelease {
4750
fn path() -> &'static Path {
4851
Path::new("/etc/os-release")
@@ -83,11 +86,11 @@ impl OsRelease {
8386
}
8487
}
8588

89+
#[cfg(target_os = "linux")]
8690
#[cfg(test)]
8791
mod test {
8892
use super::*;
8993

90-
#[cfg(target_os = "linux")]
9194
#[test]
9295
fn os_release() {
9396
if OsRelease::path().exists() {

crates/q_cli/src/cli/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ use fig_log::{
5252
initialize_logging,
5353
};
5454
use fig_proto::local::UiElement;
55+
use fig_util::directories::home_local_bin;
5556
use fig_util::{
57+
CHAT_BINARY_NAME,
5658
CLI_BINARY_NAME,
5759
PRODUCT_NAME,
5860
directories,
@@ -335,14 +337,25 @@ impl Cli {
335337
CliRootCommands::Telemetry(subcommand) => subcommand.execute().await,
336338
CliRootCommands::Version { changelog } => Self::print_version(changelog),
337339
CliRootCommands::Dashboard => launch_dashboard(false).await,
338-
CliRootCommands::Chat { args } => todo!(),
340+
CliRootCommands::Chat { args } => Self::execute_chat(Some(args)).await,
339341
CliRootCommands::Inline(subcommand) => subcommand.execute(&cli_context).await,
340342
},
341343
// Root command
342-
None => todo!(),
344+
None => Self::execute_chat(None).await,
343345
}
344346
}
345347

348+
async fn execute_chat(args: Option<Vec<String>>) -> Result<ExitCode> {
349+
let mut cmd = tokio::process::Command::new(home_local_bin()?.join(CHAT_BINARY_NAME));
350+
if let Some(args) = args {
351+
cmd.args(args);
352+
}
353+
354+
cmd.status().await?;
355+
356+
Ok(ExitCode::SUCCESS)
357+
}
358+
346359
async fn send_telemetry(&self) {
347360
match &self.subcommand {
348361
None

0 commit comments

Comments
 (0)