|
@@ -58,40 +58,44 @@ macro_rules! value_or_prompt {
|
|
|
}
|
|
|
|
|
|
fn plugin_command(matches: &ArgMatches) -> Result<()> {
|
|
|
- let api = matches.is_present("api");
|
|
|
- let plugin_name = matches.value_of("name").expect("name is required");
|
|
|
- let directory = matches.value_of("directory");
|
|
|
- let tauri_path = matches.value_of("tauri-path");
|
|
|
- let tauri = matches.is_present("tauri");
|
|
|
- let author = matches
|
|
|
- .value_of("author")
|
|
|
- .map(|p| p.to_string())
|
|
|
- .unwrap_or_else(|| {
|
|
|
- if tauri {
|
|
|
- "Tauri Programme within The Commons Conservancy".into()
|
|
|
- } else {
|
|
|
- "You".into()
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- let mut plugin_runner = plugin::Plugin::new()
|
|
|
- .plugin_name(plugin_name.to_string())
|
|
|
- .author(author);
|
|
|
+ if let Some(matches) = matches.subcommand_matches("init") {
|
|
|
+ let api = matches.is_present("api");
|
|
|
+ let plugin_name = matches.value_of("name").expect("name is required");
|
|
|
+ let directory = matches.value_of("directory");
|
|
|
+ let tauri_path = matches.value_of("tauri-path");
|
|
|
+ let tauri = matches.is_present("tauri");
|
|
|
+ let author = matches
|
|
|
+ .value_of("author")
|
|
|
+ .map(|p| p.to_string())
|
|
|
+ .unwrap_or_else(|| {
|
|
|
+ if tauri {
|
|
|
+ "Tauri Programme within The Commons Conservancy".into()
|
|
|
+ } else {
|
|
|
+ "You".into()
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ let mut plugin_runner = plugin::Plugin::new()
|
|
|
+ .plugin_name(plugin_name.to_string())
|
|
|
+ .author(author);
|
|
|
+
|
|
|
+ if api {
|
|
|
+ plugin_runner = plugin_runner.api();
|
|
|
+ }
|
|
|
+ if tauri {
|
|
|
+ plugin_runner = plugin_runner.tauri();
|
|
|
+ }
|
|
|
+ if let Some(directory) = directory {
|
|
|
+ plugin_runner = plugin_runner.directory(directory);
|
|
|
+ }
|
|
|
+ if let Some(tauri_path) = tauri_path {
|
|
|
+ plugin_runner = plugin_runner.tauri_path(tauri_path);
|
|
|
+ }
|
|
|
|
|
|
- if api {
|
|
|
- plugin_runner = plugin_runner.api();
|
|
|
- }
|
|
|
- if tauri {
|
|
|
- plugin_runner = plugin_runner.tauri();
|
|
|
- }
|
|
|
- if let Some(directory) = directory {
|
|
|
- plugin_runner = plugin_runner.directory(directory);
|
|
|
- }
|
|
|
- if let Some(tauri_path) = tauri_path {
|
|
|
- plugin_runner = plugin_runner.tauri_path(tauri_path);
|
|
|
+ plugin_runner.run()
|
|
|
+ } else {
|
|
|
+ Ok(())
|
|
|
}
|
|
|
-
|
|
|
- plugin_runner.run()
|
|
|
}
|
|
|
|
|
|
fn init_command(matches: &ArgMatches) -> Result<()> {
|
|
@@ -308,11 +312,9 @@ fn main() -> Result<()> {
|
|
|
let matches = app.get_matches();
|
|
|
|
|
|
if let Some(matches) = matches.subcommand_matches("init") {
|
|
|
- if let Some(matches) = matches.subcommand_matches("plugin") {
|
|
|
- plugin_command(matches)?;
|
|
|
- } else {
|
|
|
- init_command(matches)?;
|
|
|
- }
|
|
|
+ init_command(matches)?;
|
|
|
+ } else if let Some(matches) = matches.subcommand_matches("plugin") {
|
|
|
+ plugin_command(matches)?;
|
|
|
} else if let Some(matches) = matches.subcommand_matches("dev") {
|
|
|
dev_command(matches)?;
|
|
|
} else if let Some(matches) = matches.subcommand_matches("build") {
|