File tree Expand file tree Collapse file tree 3 files changed +22
-10
lines changed Expand file tree Collapse file tree 3 files changed +22
-10
lines changed Original file line number Diff line number Diff line change 1
- //! CLI functionality
2
-
3
1
mod chat;
4
2
mod debug;
5
3
mod diagnostics;
@@ -198,7 +196,7 @@ impl Cli {
198
196
self . send_telemetry ( ) . await ;
199
197
200
198
if self . help_all {
201
- return self . print_help_all ( ) ;
199
+ return Self :: print_help_all ( ) ;
202
200
}
203
201
204
202
let cli_context = CliContext :: new ( ) ;
@@ -229,8 +227,7 @@ impl Cli {
229
227
}
230
228
}
231
229
232
- #[ allow( clippy:: unused_self) ]
233
- fn print_help_all ( & self ) -> Result < ExitCode > {
230
+ fn print_help_all ( ) -> Result < ExitCode > {
234
231
let mut cmd = Self :: command ( ) . help_template ( "{all-args}" ) ;
235
232
eprintln ! ( ) ;
236
233
eprintln ! (
@@ -263,7 +260,6 @@ impl Cli {
263
260
Ok ( ( ) )
264
261
}
265
262
266
- #[ allow( clippy:: unused_self) ]
267
263
fn print_version ( changelog : Option < String > ) -> Result < ExitCode > {
268
264
// If no changelog is requested, display normal version information
269
265
if changelog. is_none ( ) {
Original file line number Diff line number Diff line change
1
+ #[ cfg( target_os = "linux" ) ]
1
2
use std:: io;
3
+ #[ cfg( target_os = "linux" ) ]
2
4
use std:: path:: Path ;
3
- use std:: sync:: OnceLock ;
4
5
5
6
use serde:: {
6
7
Deserialize ,
@@ -21,6 +22,7 @@ pub enum DesktopEnvironment {
21
22
Sway ,
22
23
}
23
24
25
+ #[ cfg( target_os = "linux" ) ]
24
26
pub fn get_os_release ( ) -> Option < & ' static OsRelease > {
25
27
static OS_RELEASE : OnceLock < Option < OsRelease > > = OnceLock :: new ( ) ;
26
28
OS_RELEASE . get_or_init ( || OsRelease :: load ( ) . ok ( ) ) . as_ref ( )
@@ -43,6 +45,7 @@ pub struct OsRelease {
43
45
pub variant : Option < String > ,
44
46
}
45
47
48
+ #[ cfg( target_os = "linux" ) ]
46
49
impl OsRelease {
47
50
fn path ( ) -> & ' static Path {
48
51
Path :: new ( "/etc/os-release" )
@@ -83,11 +86,11 @@ impl OsRelease {
83
86
}
84
87
}
85
88
89
+ #[ cfg( target_os = "linux" ) ]
86
90
#[ cfg( test) ]
87
91
mod test {
88
92
use super :: * ;
89
93
90
- #[ cfg( target_os = "linux" ) ]
91
94
#[ test]
92
95
fn os_release ( ) {
93
96
if OsRelease :: path ( ) . exists ( ) {
Original file line number Diff line number Diff line change @@ -52,7 +52,9 @@ use fig_log::{
52
52
initialize_logging,
53
53
} ;
54
54
use fig_proto:: local:: UiElement ;
55
+ use fig_util:: directories:: home_local_bin;
55
56
use fig_util:: {
57
+ CHAT_BINARY_NAME ,
56
58
CLI_BINARY_NAME ,
57
59
PRODUCT_NAME ,
58
60
directories,
@@ -335,14 +337,25 @@ impl Cli {
335
337
CliRootCommands :: Telemetry ( subcommand) => subcommand. execute ( ) . await ,
336
338
CliRootCommands :: Version { changelog } => Self :: print_version ( changelog) ,
337
339
CliRootCommands :: Dashboard => launch_dashboard ( false ) . await ,
338
- CliRootCommands :: Chat { args } => todo ! ( ) ,
340
+ CliRootCommands :: Chat { args } => Self :: execute_chat ( Some ( args ) ) . await ,
339
341
CliRootCommands :: Inline ( subcommand) => subcommand. execute ( & cli_context) . await ,
340
342
} ,
341
343
// Root command
342
- None => todo ! ( ) ,
344
+ None => Self :: execute_chat ( None ) . await ,
343
345
}
344
346
}
345
347
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
+
346
359
async fn send_telemetry ( & self ) {
347
360
match & self . subcommand {
348
361
None
You can’t perform that action at this time.
0 commit comments