@@ -3,7 +3,7 @@ use ::std::path::Path;
33use serde_json:: Value ;
44use urlencoding:: encode;
55
6- use tauri_plugin_cli:: CliExt ;
6+ use tauri_plugin_cli:: { ArgData , CliExt } ;
77
88use crate :: cli:: run;
99use crate :: compile;
@@ -18,7 +18,9 @@ pub fn cli(app: &mut tauri::App) -> Result<(), Box<dyn ::std::error::Error>> {
1818 // `subcommand` is `Option<Box<SubcommandMatches>>` where `SubcommandMatches` is a struct with { name, matches }.
1919 let Some ( subcommand_matches) = app. cli ( ) . matches ( ) ?. subcommand else {
2020 if let Some ( help) = app. cli ( ) . matches ( ) ?. args . get ( "help" ) {
21- return Err ( Box :: from ( help. value . as_str ( ) . or ( Some ( "Internal Error" ) ) . unwrap ( ) ) ) ;
21+ return Err ( Box :: from (
22+ help. value . as_str ( ) . or ( Some ( "Internal Error" ) ) . unwrap ( ) ,
23+ ) ) ;
2224 } else {
2325 return Err ( Box :: from ( "Internal Error" ) ) ;
2426 }
@@ -32,19 +34,29 @@ pub fn cli(app: &mut tauri::App) -> Result<(), Box<dyn ::std::error::Error>> {
3234
3335 match compile_subcommand_matches. name . as_str ( ) {
3436 "beeai" => {
35- let Some ( source) = compile_subcommand_matches. matches . args . get ( "source" ) else {
36- return Err ( Box :: from ( "Missing source file" ) ) ;
37+ // TODO this probably fails if the source is a number??
38+ let Some ( ArgData {
39+ value : Value :: String ( source_file_path) ,
40+ ..
41+ } ) = compile_subcommand_matches. matches . args . get ( "source" )
42+ else {
43+ return Err ( Box :: from ( "Invalid source file" ) ) ;
3744 } ;
38- let Value :: String ( source_file_path) = & source. value else {
39- return Err ( Box :: from ( "Invalid source file argument" ) ) ;
45+ let Some ( ArgData {
46+ value : Value :: String ( output_file_path) ,
47+ ..
48+ } ) = compile_subcommand_matches. matches . args . get ( "output" )
49+ else {
50+ return Err ( Box :: from ( "Invalid output argument" ) ) ;
4051 } ;
41- let Some ( output) = compile_subcommand_matches. matches . args . get ( "output" ) else {
42- return Err ( Box :: from ( "Missing output argument" ) ) ;
52+ let Some ( ArgData {
53+ value : Value :: Bool ( debug) ,
54+ ..
55+ } ) = compile_subcommand_matches. matches . args . get ( "debug" )
56+ else {
57+ return Err ( Box :: from ( "Invalid debug argument" ) ) ;
4358 } ;
44- let Value :: String ( output_file_path) = & output. value else {
45- return Err ( Box :: from ( "Invalid output file argument" ) ) ;
46- } ;
47- return compile:: beeai:: compile ( source_file_path, output_file_path) ;
59+ return compile:: beeai:: compile ( source_file_path, output_file_path, debug) ;
4860 }
4961 _ => { }
5062 }
0 commit comments