Download packages/tauri/crates/tauri-cli/src/plugin/new.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 2.57 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri/crates/tauri-cli/src/plugin/new.rs
- Command line
-
hf download hf://datasets/echodict/readest/packages/tauri/crates/tauri-cli/src/plugin/new.rs
-
curl -L -o new.rs https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri/crates/tauri-cli/src/plugin/new.rs
2.57 kB
| // Copyright 2019-2024 Tauri Programme within The Commons Conservancy | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // SPDX-License-Identifier: MIT | |
| use super::PluginIosFramework; | |
| use crate::{ | |
| error::{Context, ErrorExt}, | |
| Result, | |
| }; | |
| use clap::Parser; | |
| use std::path::PathBuf; | |
| pub struct Options { | |
| /// Name of your Tauri plugin | |
| plugin_name: String, | |
| /// Initializes a Tauri plugin without the TypeScript API | |
| no_api: bool, | |
| /// Initialize without an example project. | |
| no_example: bool, | |
| /// Set target directory for init | |
| directory: Option<String>, | |
| /// Author name | |
| author: Option<String>, | |
| /// Whether to initialize an Android project for the plugin. | |
| android: bool, | |
| /// Whether to initialize an iOS project for the plugin. | |
| ios: bool, | |
| /// Whether to initialize Android and iOS projects for the plugin. | |
| mobile: bool, | |
| /// Type of framework to use for the iOS project. | |
| pub(crate) ios_framework: PluginIosFramework, | |
| /// Generate github workflows | |
| github_workflows: bool, | |
| /// Initializes a Tauri core plugin (internal usage) | |
| tauri: bool, | |
| /// Path of the Tauri project to use (relative to the cwd) | |
| tauri_path: Option<PathBuf>, | |
| } | |
| impl From<Options> for super::init::Options { | |
| fn from(o: Options) -> Self { | |
| Self { | |
| plugin_name: Some(o.plugin_name), | |
| no_api: o.no_api, | |
| no_example: o.no_example, | |
| directory: o.directory.unwrap(), | |
| author: o.author, | |
| android: o.android, | |
| ios: o.ios, | |
| mobile: o.mobile, | |
| ios_framework: o.ios_framework, | |
| github_workflows: o.github_workflows, | |
| tauri: o.tauri, | |
| tauri_path: o.tauri_path, | |
| } | |
| } | |
| } | |
| pub fn command(mut options: Options) -> Result<()> { | |
| let cwd = std::env::current_dir().context("failed to get current directory")?; | |
| if let Some(dir) = &options.directory { | |
| std::fs::create_dir_all(cwd.join(dir)) | |
| .fs_context("failed to create crate directory", cwd.join(dir))?; | |
| } else { | |
| let target = cwd.join(format!("tauri-plugin-{}", options.plugin_name)); | |
| std::fs::create_dir_all(&target) | |
| .fs_context("failed to create crate directory", target.clone())?; | |
| options.directory.replace(target.display().to_string()); | |
| } | |
| super::init::command(options.into()) | |
| } | |