diff --git a/.changes/cli-plugin-no-example.md b/.changes/cli-plugin-no-example.md new file mode 100644 index 000000000000..3648c20ceb0b --- /dev/null +++ b/.changes/cli-plugin-no-example.md @@ -0,0 +1,7 @@ +--- +"tauri-cli": "patch:feat" +"@tauri-apps/cli": "patch:feat" +--- + +Add `--no-example` flag for `tauri plugin new` and `tauri plugin init` to disable creation of an example project. + diff --git a/crates/tauri-cli/src/plugin/init.rs b/crates/tauri-cli/src/plugin/init.rs index f23cc3349e3f..238283b3e008 100644 --- a/crates/tauri-cli/src/plugin/init.rs +++ b/crates/tauri-cli/src/plugin/init.rs @@ -33,16 +33,13 @@ pub struct Options { /// Initializes a Tauri plugin without the TypeScript API #[clap(long)] pub(crate) no_api: bool, - /// Initializes a Tauri core plugin (internal usage) - #[clap(long, hide(true))] - pub(crate) tauri: bool, + /// Initialize without an example project. + #[clap(long)] + pub(crate) no_example: bool, /// Set target directory for init #[clap(short, long)] #[clap(default_value_t = current_dir().expect("failed to read cwd").display().to_string())] pub(crate) directory: String, - /// Path of the Tauri project to use (relative to the cwd) - #[clap(short, long)] - pub(crate) tauri_path: Option, /// Author name #[clap(short, long)] pub(crate) author: Option, @@ -59,6 +56,13 @@ pub struct Options { #[clap(long)] #[clap(default_value_t = PluginIosFramework::default())] pub(crate) ios_framework: PluginIosFramework, + + /// Initializes a Tauri core plugin (internal usage) + #[clap(long, hide(true))] + pub(crate) tauri: bool, + /// Path of the Tauri project to use (relative to the cwd) + #[clap(short, long)] + pub(crate) tauri_path: Option, } impl Options { @@ -176,14 +180,14 @@ pub fn command(mut options: Options) -> Result<()> { if let Component::Normal(component) = root { match component.to_str().unwrap() { "__example-api" => { - if options.no_api { + if options.no_api || options.no_example { return Ok(None); } else { path = Path::new("examples").join(components.collect::()); } } "__example-basic" => { - if options.no_api { + if options.no_api && !options.no_example { path = Path::new("examples").join(components.collect::()); } else { return Ok(None); diff --git a/crates/tauri-cli/src/plugin/new.rs b/crates/tauri-cli/src/plugin/new.rs index ca17994106af..55205858767a 100644 --- a/crates/tauri-cli/src/plugin/new.rs +++ b/crates/tauri-cli/src/plugin/new.rs @@ -15,15 +15,12 @@ pub struct Options { /// Initializes a Tauri plugin without the TypeScript API #[clap(long)] no_api: bool, - /// Initializes a Tauri core plugin (internal usage) - #[clap(long, hide(true))] - tauri: bool, + /// Initialize without an example project. + #[clap(long)] + no_example: bool, /// Set target directory for init #[clap(short, long)] directory: Option, - /// Path of the Tauri project to use (relative to the cwd) - #[clap(short, long)] - tauri_path: Option, /// Author name #[clap(short, long)] author: Option, @@ -40,6 +37,13 @@ pub struct Options { #[clap(long)] #[clap(default_value_t = PluginIosFramework::default())] pub(crate) ios_framework: PluginIosFramework, + + /// Initializes a Tauri core plugin (internal usage) + #[clap(long, hide(true))] + tauri: bool, + /// Path of the Tauri project to use (relative to the cwd) + #[clap(short, long)] + tauri_path: Option, } impl From for super::init::Options { @@ -47,14 +51,16 @@ impl From for super::init::Options { Self { plugin_name: Some(o.plugin_name), no_api: o.no_api, - tauri: o.tauri, + no_example: o.no_example, directory: o.directory.unwrap(), - tauri_path: o.tauri_path, author: o.author, android: o.android, ios: o.ios, mobile: o.mobile, ios_framework: o.ios_framework, + + tauri: o.tauri, + tauri_path: o.tauri_path, } } }