@@ -4,13 +4,16 @@ use building::*;
44
55fn usage ( ) {
66 eprintln ! ( ) ;
7- eprintln ! ( "Usage: cargo run [<command>] [release|debug|profiling]" ) ;
7+ eprintln ! ( "Usage: cargo run [<command>] [release|debug|profiling] -- [args...] " ) ;
88 eprintln ! ( ) ;
99 eprintln ! ( "Commands:" ) ;
1010 eprintln ! ( " web [run] Run the web app on local dev server" ) ;
1111 eprintln ! ( " web build Build the web app" ) ;
1212 eprintln ! ( " desktop [run] Run the desktop app" ) ;
1313 eprintln ! ( " desktop build Build the desktop app" ) ;
14+ eprintln ! ( " cli [run] Run the Graphen CLI" ) ;
15+ eprintln ! ( " cli build Build the Graphen CLI" ) ;
16+ eprintln ! ( " help Show this message" ) ;
1417 eprintln ! ( ) ;
1518}
1619
@@ -45,29 +48,30 @@ fn run_task(task: &Task) -> Result<(), Error> {
4548 ( Target :: Web , Action :: Build , Profile :: Release | Profile :: Default ) => npm_run_in_frontend_dir ( "build" ) ?,
4649 ( Target :: Web , Action :: Build , Profile :: Profiling ) => npm_run_in_frontend_dir ( "build-profiling" ) ?,
4750
48- ( Target :: Desktop , Action :: Run , Profile :: Debug | Profile :: Default ) => {
49- npm_run_in_frontend_dir ( "build-native-dev" ) ?;
51+ ( Target :: Desktop , action, profile) => {
52+ if matches ! ( ( action, profile) , ( _, Profile :: Release ) | ( Action :: Build , Profile :: Default ) ) {
53+ npm_run_in_frontend_dir ( "build-native" ) ?;
54+ } else {
55+ npm_run_in_frontend_dir ( "build-native-dev" ) ?;
56+ } ;
5057 run ( "cargo run -p third-party-licenses --features desktop" ) ?;
51- run ( "cargo run -p graphite-desktop-bundle -- open" ) ?;
52- }
53- ( Target :: Desktop , Action :: Run , Profile :: Release ) => {
54- npm_run_in_frontend_dir ( "build-native" ) ?;
55- run ( "cargo run -p third-party-licenses --features desktop" ) ?;
56- run ( "cargo run -r -p graphite-desktop-bundle -- open" ) ?;
57- }
58- ( Target :: Desktop , Action :: Run , Profile :: Profiling ) => todo ! ( "profiling run for desktop" ) ,
5958
60- ( Target :: Desktop , Action :: Build , Profile :: Debug ) => {
61- npm_run_in_frontend_dir ( "build-native-dev" ) ?;
62- run ( "cargo run -p third-party-licenses --features desktop" ) ?;
63- run ( "cargo run -p graphite-desktop-bundle" ) ?;
59+ let cargo_profile = match profile {
60+ Profile :: Debug | Profile :: Default => "dev" ,
61+ Profile :: Release => "release" ,
62+ Profile :: Profiling => "profiling" ,
63+ } ;
64+ let args = if let Action :: Run = action { format ! ( " -- open {}" , task. args. join( " " ) ) } else { "" . to_string ( ) } ;
65+ run ( & format ! ( "cargo run --profile {cargo_profile} -p graphite-desktop-bundle{args}" ) ) ?;
6466 }
65- ( Target :: Desktop , Action :: Build , Profile :: Release | Profile :: Default ) => {
66- npm_run_in_frontend_dir ( "build-native" ) ?;
67- run ( "cargo run -p third-party-licenses --features desktop" ) ?;
68- run ( "cargo run -r -p graphite-desktop-bundle" ) ?;
69- }
70- ( Target :: Desktop , Action :: Build , Profile :: Profiling ) => todo ! ( "profiling build for desktop" ) ,
67+
68+ ( Target :: Cli , Action :: Run , Profile :: Debug | Profile :: Default ) => run ( & format ! ( "cargo run -p graphene-cli -- {}" , task. args. join( " " ) ) ) ?,
69+ ( Target :: Cli , Action :: Run , Profile :: Release ) => run ( & format ! ( "cargo run -r -p graphene-cli -- {}" , task. args. join( " " ) ) ) ?,
70+ ( Target :: Cli , Action :: Run , Profile :: Profiling ) => run ( & format ! ( "cargo run --profile profiling -p graphene-cli -- {}" , task. args. join( " " ) ) ) ?,
71+
72+ ( Target :: Cli , Action :: Build , Profile :: Debug ) => run ( "cargo build -p graphene-cli" ) ?,
73+ ( Target :: Cli , Action :: Build , Profile :: Release | Profile :: Default ) => run ( "cargo build -r -p graphene-cli" ) ?,
74+ ( Target :: Cli , Action :: Build , Profile :: Profiling ) => run ( "cargo build --profile profiling -p graphene-cli" ) ?,
7175 }
7276 Ok ( ( ) )
7377}
0 commit comments