From 2fe8782ad40c246514c1dc3f41da5ecfc8086e82 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 16 Oct 2023 15:44:23 +0300 Subject: [PATCH] refactor: enhance the descriptions of CLI commands, closes #7572 (#7952) Co-authored-by: Lucas Fernandes Nogueira Co-authored-by: Lucas Nogueira --- tooling/cli/src/add.rs | 2 +- tooling/cli/src/build.rs | 5 ++++- tooling/cli/src/completions.rs | 2 +- tooling/cli/src/dev.rs | 6 +++++- tooling/cli/src/icon.rs | 2 +- tooling/cli/src/info/mod.rs | 4 +++- tooling/cli/src/init.rs | 2 +- tooling/cli/src/lib.rs | 16 ++++++++-------- tooling/cli/src/mobile/android/build.rs | 5 ++++- tooling/cli/src/mobile/android/dev.rs | 5 ++++- .../src/mobile/{android.rs => android/mod.rs} | 2 +- tooling/cli/src/mobile/ios/build.rs | 5 ++++- tooling/cli/src/mobile/ios/dev.rs | 5 ++++- tooling/cli/src/mobile/{ios.rs => ios/mod.rs} | 2 +- tooling/cli/src/plugin/android.rs | 2 +- tooling/cli/src/plugin/init.rs | 2 +- tooling/cli/src/plugin/ios.rs | 2 +- tooling/cli/src/{plugin.rs => plugin/mod.rs} | 2 +- tooling/cli/src/plugin/new.rs | 2 +- tooling/cli/src/signer/generate.rs | 2 +- tooling/cli/src/{signer.rs => signer/mod.rs} | 2 +- 21 files changed, 49 insertions(+), 28 deletions(-) rename tooling/cli/src/mobile/{android.rs => android/mod.rs} (99%) rename tooling/cli/src/mobile/{ios.rs => ios/mod.rs} (99%) rename tooling/cli/src/{plugin.rs => plugin/mod.rs} (97%) rename tooling/cli/src/{signer.rs => signer/mod.rs} (91%) diff --git a/tooling/cli/src/add.rs b/tooling/cli/src/add.rs index 2c7340953467..743be707afc7 100644 --- a/tooling/cli/src/add.rs +++ b/tooling/cli/src/add.rs @@ -17,7 +17,7 @@ use crate::{ use std::{collections::HashMap, process::Command}; #[derive(Debug, Parser)] -#[clap(about = "Installs a plugin on the project")] +#[clap(about = "Add a tauri plugin to the project")] pub struct Options { /// The plugin to add. plugin: String, diff --git a/tooling/cli/src/build.rs b/tooling/cli/src/build.rs index a9a7e4bc3614..9fd745a2829e 100644 --- a/tooling/cli/src/build.rs +++ b/tooling/cli/src/build.rs @@ -26,7 +26,10 @@ use tauri_bundler::bundle::{bundle_project, Bundle, PackageType}; use tauri_utils::platform::Target; #[derive(Debug, Clone, Parser)] -#[clap(about = "Tauri build")] +#[clap( + about = "Build your app in release mode and generate bundles and installers", + long_about = "Build your app in release mode and generate bundles and installers. It makes use of the `build.distDir` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.distDir`. This will also run `build.beforeBundleCommand` before generating the bundles and installers of your app." +)] pub struct Options { /// Binary to use to build the application, defaults to `cargo` #[clap(short, long)] diff --git a/tooling/cli/src/completions.rs b/tooling/cli/src/completions.rs index 874e5d2a0ce2..192299a64d77 100644 --- a/tooling/cli/src/completions.rs +++ b/tooling/cli/src/completions.rs @@ -13,7 +13,7 @@ use std::{fs::write, path::PathBuf}; const PKG_MANAGERS: &[&str] = &["cargo", "pnpm", "npm", "yarn"]; #[derive(Debug, Clone, Parser)] -#[clap(about = "Shell completions")] +#[clap(about = "Generate Tauri CLI shell completions for Bash, Zsh, PowerShell or Fish")] pub struct Options { /// Shell to generate a completion script for. #[clap(short, long, verbatim_doc_comment)] diff --git a/tooling/cli/src/dev.rs b/tooling/cli/src/dev.rs index 734cfa443d32..a96d0473381e 100644 --- a/tooling/cli/src/dev.rs +++ b/tooling/cli/src/dev.rs @@ -39,7 +39,11 @@ const KILL_CHILDREN_SCRIPT: &[u8] = include_bytes!("../scripts/kill-children.sh" pub const TAURI_DEV_WATCHER_GITIGNORE: &[u8] = include_bytes!("../tauri-dev-watcher.gitignore"); #[derive(Debug, Clone, Parser)] -#[clap(about = "Tauri dev", trailing_var_arg(true))] +#[clap( + about = "Run your app in development mode", + long_about = "Run your app in development mode with hot-reloading for the Rust code. It makes use of the `build.devPath` property from your `tauri.conf.json` file. It also runs your `build.beforeDevCommand` which usually starts your frontend devServer.", + trailing_var_arg(true) +)] pub struct Options { /// Binary to use to run the application #[clap(short, long)] diff --git a/tooling/cli/src/icon.rs b/tooling/cli/src/icon.rs index 3732caec4b38..09f6ff2ea372 100644 --- a/tooling/cli/src/icon.rs +++ b/tooling/cli/src/icon.rs @@ -39,7 +39,7 @@ struct PngEntry { } #[derive(Debug, Parser)] -#[clap(about = "Generates various icons for all major platforms")] +#[clap(about = "Generate various icons for all major platforms")] pub struct Options { // TODO: Confirm 1240px /// Path to the source icon (png, 1240x1240px with transparency). diff --git a/tooling/cli/src/info/mod.rs b/tooling/cli/src/info/mod.rs index 329337b12f6d..92afc6fe76a8 100644 --- a/tooling/cli/src/info/mod.rs +++ b/tooling/cli/src/info/mod.rs @@ -200,7 +200,9 @@ impl Section<'_> { } #[derive(Debug, Parser)] -#[clap(about = "Shows information about Tauri dependencies and project configuration")] +#[clap( + about = "Show a concise list of information about the environment, Rust, Node.js and their versions as well as a few relevant project configurations" +)] pub struct Options { /// Interactive mode to apply automatic fixes. #[clap(long)] diff --git a/tooling/cli/src/init.rs b/tooling/cli/src/init.rs index 02623d008bce..5ffc76d6b984 100644 --- a/tooling/cli/src/init.rs +++ b/tooling/cli/src/init.rs @@ -30,7 +30,7 @@ const TEMPLATE_DIR: Dir<'_> = include_dir!("templates/app"); const TAURI_CONF_TEMPLATE: &str = include_str!("../templates/tauri.conf.json"); #[derive(Debug, Parser)] -#[clap(about = "Initializes a Tauri project")] +#[clap(about = "Initialize a Tauri project in an existing directory")] pub struct Options { /// Skip prompting for values #[clap(long)] diff --git a/tooling/cli/src/lib.rs b/tooling/cli/src/lib.rs index f60ed8067706..5c2fdb839a04 100644 --- a/tooling/cli/src/lib.rs +++ b/tooling/cli/src/lib.rs @@ -98,20 +98,20 @@ pub(crate) struct Cli { #[derive(Subcommand)] enum Commands { - Build(build::Options), - Dev(dev::Options), - Add(add::Options), - Icon(icon::Options), - Info(info::Options), Init(init::Options), - Plugin(plugin::Cli), - Signer(signer::Cli), - Completions(completions::Options), + Dev(dev::Options), + Build(build::Options), Android(mobile::android::Cli), #[cfg(target_os = "macos")] Ios(mobile::ios::Cli), /// Migrate from v1 to v2 Migrate, + Info(info::Options), + Add(add::Options), + Plugin(plugin::Cli), + Icon(icon::Options), + Signer(signer::Cli), + Completions(completions::Options), } fn format_error(err: clap::Error) -> clap::Error { diff --git a/tooling/cli/src/mobile/android/build.rs b/tooling/cli/src/mobile/android/build.rs index a24385db0f1d..2cfa76c2a20a 100644 --- a/tooling/cli/src/mobile/android/build.rs +++ b/tooling/cli/src/mobile/android/build.rs @@ -29,7 +29,10 @@ use cargo_mobile2::{ use std::env::{set_current_dir, set_var}; #[derive(Debug, Clone, Parser)] -#[clap(about = "Android build")] +#[clap( + about = "Build your app in release mode for Android and generate APKs and AABs", + long_about = "Build your app in release mode for Android and generate APKs and AABs. It makes use of the `build.distDir` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.distDir`." +)] pub struct Options { /// Builds with the debug flag #[clap(short, long)] diff --git a/tooling/cli/src/mobile/android/dev.rs b/tooling/cli/src/mobile/android/dev.rs index 95e2e9b14514..84ccb79f5cdd 100644 --- a/tooling/cli/src/mobile/android/dev.rs +++ b/tooling/cli/src/mobile/android/dev.rs @@ -44,7 +44,10 @@ const WEBVIEW_CLASS_INIT: &str = "this.settings.mixedContentMode = android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW"; #[derive(Debug, Clone, Parser)] -#[clap(about = "Android dev")] +#[clap( + about = "Run your app in development mode on Android", + long_about = "Run your app in development mode on Android with hot-reloading for the Rust code. It makes use of the `build.devPath` property from your `tauri.conf.json` file. It also runs your `build.beforeDevCommand` which usually starts your frontend devServer." +)] pub struct Options { /// List of cargo features to activate #[clap(short, long, action = ArgAction::Append, num_args(0..))] diff --git a/tooling/cli/src/mobile/android.rs b/tooling/cli/src/mobile/android/mod.rs similarity index 99% rename from tooling/cli/src/mobile/android.rs rename to tooling/cli/src/mobile/android/mod.rs index 2c70a7fb5091..1a622c7b40c6 100644 --- a/tooling/cli/src/mobile/android.rs +++ b/tooling/cli/src/mobile/android/mod.rs @@ -54,7 +54,7 @@ pub struct Cli { } #[derive(Debug, Parser)] -#[clap(about = "Initializes a Tauri Android project")] +#[clap(about = "Initialize Android target in the project")] pub struct InitOptions { /// Skip prompting for values #[clap(long)] diff --git a/tooling/cli/src/mobile/ios/build.rs b/tooling/cli/src/mobile/ios/build.rs index 115b024f52a2..76c3d03be181 100644 --- a/tooling/cli/src/mobile/ios/build.rs +++ b/tooling/cli/src/mobile/ios/build.rs @@ -30,7 +30,10 @@ use cargo_mobile2::{ use std::{env::set_current_dir, fs}; #[derive(Debug, Clone, Parser)] -#[clap(about = "iOS build")] +#[clap( + about = "Build your app in release mode for iOS and generate IPAs", + long_about = "Build your app in release mode for iOS and generate IPAs. It makes use of the `build.distDir` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.distDir`." +)] pub struct Options { /// Builds with the debug flag #[clap(short, long)] diff --git a/tooling/cli/src/mobile/ios/dev.rs b/tooling/cli/src/mobile/ios/dev.rs index 6b4de60d0aa9..0dd16cbe0c23 100644 --- a/tooling/cli/src/mobile/ios/dev.rs +++ b/tooling/cli/src/mobile/ios/dev.rs @@ -31,7 +31,10 @@ use dialoguer::{theme::ColorfulTheme, Select}; use std::env::{set_current_dir, set_var, var_os}; #[derive(Debug, Clone, Parser)] -#[clap(about = "iOS dev")] +#[clap( + about = "Run your app in development mode on iOS", + long_about = "Run your app in development mode on iOS with hot-reloading for the Rust code. It makes use of the `build.devPath` property from your `tauri.conf.json` file. It also runs your `build.beforeDevCommand` which usually starts your frontend devServer." +)] pub struct Options { /// List of cargo features to activate #[clap(short, long, action = ArgAction::Append, num_args(0..))] diff --git a/tooling/cli/src/mobile/ios.rs b/tooling/cli/src/mobile/ios/mod.rs similarity index 99% rename from tooling/cli/src/mobile/ios.rs rename to tooling/cli/src/mobile/ios/mod.rs index d8ee730748a1..f500465f89ef 100644 --- a/tooling/cli/src/mobile/ios.rs +++ b/tooling/cli/src/mobile/ios/mod.rs @@ -54,7 +54,7 @@ pub struct Cli { } #[derive(Debug, Parser)] -#[clap(about = "Initializes a Tauri iOS project")] +#[clap(about = "Initialize iOS target in the project")] pub struct InitOptions { /// Skip prompting for values #[clap(long)] diff --git a/tooling/cli/src/plugin/android.rs b/tooling/cli/src/plugin/android.rs index 82bcfd4ef79d..b1f538b79e19 100644 --- a/tooling/cli/src/plugin/android.rs +++ b/tooling/cli/src/plugin/android.rs @@ -17,7 +17,7 @@ use std::{ #[clap( author, version, - about = "Manage the Android project for Tauri plugins", + about = "Manage the Android project for a Tauri plugin", subcommand_required(true), arg_required_else_help(true) )] diff --git a/tooling/cli/src/plugin/init.rs b/tooling/cli/src/plugin/init.rs index 6229dce6231a..ef1c089ae719 100644 --- a/tooling/cli/src/plugin/init.rs +++ b/tooling/cli/src/plugin/init.rs @@ -27,7 +27,7 @@ use std::{ pub const TEMPLATE_DIR: Dir<'_> = include_dir!("templates/plugin"); #[derive(Debug, Parser)] -#[clap(about = "Initializes a Tauri plugin project")] +#[clap(about = "Initialize a Tauri plugin project on an existing directory")] pub struct Options { /// Name of your Tauri plugin. /// If not specified, it will be infered from the current directory. diff --git a/tooling/cli/src/plugin/ios.rs b/tooling/cli/src/plugin/ios.rs index 1b44e3e3a15b..104a7759b31f 100644 --- a/tooling/cli/src/plugin/ios.rs +++ b/tooling/cli/src/plugin/ios.rs @@ -18,7 +18,7 @@ use std::{ #[clap( author, version, - about = "Manage the iOS project for Tauri plugins", + about = "Manage the iOS project for a Tauri plugin", subcommand_required(true), arg_required_else_help(true) )] diff --git a/tooling/cli/src/plugin.rs b/tooling/cli/src/plugin/mod.rs similarity index 97% rename from tooling/cli/src/plugin.rs rename to tooling/cli/src/plugin/mod.rs index 481b85991122..13f48a6fddfa 100644 --- a/tooling/cli/src/plugin.rs +++ b/tooling/cli/src/plugin/mod.rs @@ -17,7 +17,7 @@ mod new; #[clap( author, version, - about = "Manage Tauri plugins", + about = "Manage or create Tauri plugins", subcommand_required(true), arg_required_else_help(true) )] diff --git a/tooling/cli/src/plugin/new.rs b/tooling/cli/src/plugin/new.rs index 9e6a89c28d45..15d406c7390a 100644 --- a/tooling/cli/src/plugin/new.rs +++ b/tooling/cli/src/plugin/new.rs @@ -7,7 +7,7 @@ use clap::Parser; use std::path::PathBuf; #[derive(Debug, Parser)] -#[clap(about = "Initializes a Tauri plugin project")] +#[clap(about = "Initializes a new Tauri plugin project")] pub struct Options { /// Name of your Tauri plugin plugin_name: String, diff --git a/tooling/cli/src/signer/generate.rs b/tooling/cli/src/signer/generate.rs index 5bcb69c25d6c..bd65c3921366 100644 --- a/tooling/cli/src/signer/generate.rs +++ b/tooling/cli/src/signer/generate.rs @@ -11,7 +11,7 @@ use std::path::PathBuf; use tauri_utils::display_path; #[derive(Debug, Parser)] -#[clap(about = "Generate keypair to sign files")] +#[clap(about = "Generate a new signing key to sign files")] pub struct Options { /// Set private key password when signing #[clap(short, long)] diff --git a/tooling/cli/src/signer.rs b/tooling/cli/src/signer/mod.rs similarity index 91% rename from tooling/cli/src/signer.rs rename to tooling/cli/src/signer/mod.rs index f14479f96f60..ec461ee7a201 100644 --- a/tooling/cli/src/signer.rs +++ b/tooling/cli/src/signer/mod.rs @@ -12,7 +12,7 @@ mod sign; #[clap( author, version, - about = "Tauri updater signer", + about = "Generate signing keys for Tauri updater or sign files", subcommand_required(true), arg_required_else_help(true) )]