mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
refactor(cli.rs): rename init plugin subcommand to plugin init (#2885)
This commit is contained in:
committed by
GitHub
parent
dfe508d492
commit
db275f0b63
@@ -2,4 +2,4 @@
|
||||
"cli.rs": patch
|
||||
---
|
||||
|
||||
Added `$ tauri init plugin` command, which initializes a Tauri plugin.
|
||||
Added `$ tauri plugin init` command, which initializes a Tauri plugin.
|
||||
|
||||
@@ -124,7 +124,6 @@ subcommands:
|
||||
long: force
|
||||
about: Overwrite private key even if it exists on the specified path
|
||||
requires: generate
|
||||
|
||||
- info:
|
||||
about: Shows information about Tauri dependencies
|
||||
- init:
|
||||
@@ -171,35 +170,37 @@ subcommands:
|
||||
long: dev-path
|
||||
about: Url of your dev server
|
||||
takes_value: true
|
||||
- plugin:
|
||||
about: Manage Tauri plugins.
|
||||
subcommands:
|
||||
- plugin:
|
||||
about: Initializes a Tauri plugin project.
|
||||
args:
|
||||
- name:
|
||||
short: n
|
||||
long: name
|
||||
about: Name of your Tauri plugin
|
||||
takes_value: true
|
||||
required: true
|
||||
- directory:
|
||||
short: d
|
||||
long: directory
|
||||
about: Set target directory for init
|
||||
takes_value: true
|
||||
- tauri-path:
|
||||
short: t
|
||||
long: tauri-path
|
||||
about: Path of the Tauri project to use (relative to the cwd)
|
||||
takes_value: true
|
||||
- api:
|
||||
short: a
|
||||
long: api
|
||||
about: Initializes a Tauri plugin with TypeScript API.
|
||||
- author:
|
||||
long: author
|
||||
about: Author name.
|
||||
takes_value: true
|
||||
- tauri:
|
||||
long: tauri
|
||||
about: Initializes a Tauri core plugin (internal usage).
|
||||
setting: Hidden
|
||||
- init:
|
||||
about: Initializes a Tauri plugin project.
|
||||
args:
|
||||
- name:
|
||||
short: n
|
||||
long: name
|
||||
about: Name of your Tauri plugin
|
||||
takes_value: true
|
||||
required: true
|
||||
- directory:
|
||||
short: d
|
||||
long: directory
|
||||
about: Set target directory for init
|
||||
takes_value: true
|
||||
- tauri-path:
|
||||
short: t
|
||||
long: tauri-path
|
||||
about: Path of the Tauri project to use (relative to the cwd)
|
||||
takes_value: true
|
||||
- api:
|
||||
short: a
|
||||
long: api
|
||||
about: Initializes a Tauri plugin with TypeScript API.
|
||||
- author:
|
||||
long: author
|
||||
about: Author name.
|
||||
takes_value: true
|
||||
- tauri:
|
||||
long: tauri
|
||||
about: Initializes a Tauri core plugin (internal usage).
|
||||
setting: Hidden
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
});
|
||||
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);
|
||||
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()
|
||||
plugin_runner.run()
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
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") {
|
||||
|
||||
Reference in New Issue
Block a user