@@ -58,40 +58,44 @@ macro_rules! value_or_prompt {
5858}
5959
6060fn plugin_command ( matches : & ArgMatches ) -> Result < ( ) > {
61- let api = matches. is_present ( "api" ) ;
62- let plugin_name = matches. value_of ( "name" ) . expect ( "name is required" ) ;
63- let directory = matches. value_of ( "directory" ) ;
64- let tauri_path = matches. value_of ( "tauri-path" ) ;
65- let tauri = matches. is_present ( "tauri" ) ;
66- let author = matches
67- . value_of ( "author" )
68- . map ( |p| p. to_string ( ) )
69- . unwrap_or_else ( || {
70- if tauri {
71- "Tauri Programme within The Commons Conservancy" . into ( )
72- } else {
73- "You" . into ( )
74- }
75- } ) ;
76-
77- let mut plugin_runner = plugin:: Plugin :: new ( )
78- . plugin_name ( plugin_name. to_string ( ) )
79- . author ( author) ;
61+ if let Some ( matches) = matches. subcommand_matches ( "init" ) {
62+ let api = matches. is_present ( "api" ) ;
63+ let plugin_name = matches. value_of ( "name" ) . expect ( "name is required" ) ;
64+ let directory = matches. value_of ( "directory" ) ;
65+ let tauri_path = matches. value_of ( "tauri-path" ) ;
66+ let tauri = matches. is_present ( "tauri" ) ;
67+ let author = matches
68+ . value_of ( "author" )
69+ . map ( |p| p. to_string ( ) )
70+ . unwrap_or_else ( || {
71+ if tauri {
72+ "Tauri Programme within The Commons Conservancy" . into ( )
73+ } else {
74+ "You" . into ( )
75+ }
76+ } ) ;
77+
78+ let mut plugin_runner = plugin:: Plugin :: new ( )
79+ . plugin_name ( plugin_name. to_string ( ) )
80+ . author ( author) ;
81+
82+ if api {
83+ plugin_runner = plugin_runner. api ( ) ;
84+ }
85+ if tauri {
86+ plugin_runner = plugin_runner. tauri ( ) ;
87+ }
88+ if let Some ( directory) = directory {
89+ plugin_runner = plugin_runner. directory ( directory) ;
90+ }
91+ if let Some ( tauri_path) = tauri_path {
92+ plugin_runner = plugin_runner. tauri_path ( tauri_path) ;
93+ }
8094
81- if api {
82- plugin_runner = plugin_runner. api ( ) ;
83- }
84- if tauri {
85- plugin_runner = plugin_runner. tauri ( ) ;
86- }
87- if let Some ( directory) = directory {
88- plugin_runner = plugin_runner. directory ( directory) ;
89- }
90- if let Some ( tauri_path) = tauri_path {
91- plugin_runner = plugin_runner. tauri_path ( tauri_path) ;
95+ plugin_runner. run ( )
96+ } else {
97+ Ok ( ( ) )
9298 }
93-
94- plugin_runner. run ( )
9599}
96100
97101fn init_command ( matches : & ArgMatches ) -> Result < ( ) > {
@@ -308,11 +312,9 @@ fn main() -> Result<()> {
308312 let matches = app. get_matches ( ) ;
309313
310314 if let Some ( matches) = matches. subcommand_matches ( "init" ) {
311- if let Some ( matches) = matches. subcommand_matches ( "plugin" ) {
312- plugin_command ( matches) ?;
313- } else {
314- init_command ( matches) ?;
315- }
315+ init_command ( matches) ?;
316+ } else if let Some ( matches) = matches. subcommand_matches ( "plugin" ) {
317+ plugin_command ( matches) ?;
316318 } else if let Some ( matches) = matches. subcommand_matches ( "dev" ) {
317319 dev_command ( matches) ?;
318320 } else if let Some ( matches) = matches. subcommand_matches ( "build" ) {
0 commit comments