Skip to content

Commit

Permalink
chore(cli): update clap to 3.1 (#3568)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Feb 27, 2022
1 parent 913fb00 commit b10a7cf
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 66 deletions.
12 changes: 6 additions & 6 deletions examples/api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
svelte-hmr "^0.14.7"

"@tauri-apps/api@../../tooling/api/dist":
version "1.0.0-rc.0"
version "1.0.0-rc.1"
dependencies:
type-fest "2.8.0"
type-fest "2.12.0"

debug@^4.3.2:
version "4.3.3"
Expand Down Expand Up @@ -262,10 +262,10 @@ svelte@3.35.0:
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.35.0.tgz#e0d0ba60c4852181c2b4fd851194be6fda493e65"
integrity sha512-gknlZkR2sXheu/X+B7dDImwANVvK1R0QGQLd8CNIfxxGPeXBmePnxfzb6fWwTQRsYQG7lYkZXvpXJvxvpsoB7g==

type-fest@2.8.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.8.0.tgz#39d7c9f9c508df8d6ce1cf5a966b0e6568dcc50d"
integrity sha512-O+V9pAshf9C6loGaH0idwsmugI2LxVNR7DtS40gVo2EXZVYFgz9OuNtOhgHLdHdapOEWNdvz9Ob/eeuaWwwlxA==
type-fest@2.12.0:
version "2.12.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.12.0.tgz#ce342f58cab9114912f54b493d60ab39c3fc82b6"
integrity sha512-Qe5GRT+n/4GoqCNGGVp5Snapg1Omq3V7irBJB3EaKsp7HWDo5Gv2d/67gfNyV+d5EXD+x/RF5l1h4yJ7qNkcGA==

vite@^2.6.4:
version "2.6.14"
Expand Down
1 change: 1 addition & 0 deletions tooling/bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ tauri-utils = { version = "1.0.0-rc.2", path = "../../core/tauri-utils", feature
ar = "0.9.0"
icns = "0.3"
image = "0.24.1"
png = "=0.17.3"
libflate = "1.1"
md5 = "0.7.0"
anyhow = "1.0"
Expand Down
63 changes: 32 additions & 31 deletions tooling/cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tooling/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ name = "cargo-tauri"
path = "src/main.rs"

[dependencies]
clap = { version = "3", features = [ "derive" ] }
clap = { version = "3.1", features = [ "derive" ] }
anyhow = "1.0"
tauri-bundler = { version = "1.0.0-rc.2", path = "../bundler" }
colored = "2.0"
Expand Down
6 changes: 0 additions & 6 deletions tooling/cli/node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,4 @@

/* auto-generated by NAPI-RS */

export class ExternalObject<T> {
readonly '': {
readonly '': unique symbol
[K: symbol]: T
}
}
export function run(args: Array<string>, binName: string | undefined | null, callback: (...args: any[]) => any): void
5 changes: 2 additions & 3 deletions tooling/cli/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
},
CommandExt, Result,
};
use clap::{AppSettings, Parser};
use clap::Parser;

use anyhow::Context;
use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
Expand All @@ -33,8 +33,7 @@ use std::{
static BEFORE_DEV: OnceCell<Mutex<Arc<SharedChild>>> = OnceCell::new();

#[derive(Debug, Parser)]
#[clap(about = "Tauri dev")]
#[clap(setting(AppSettings::TrailingVarArg))]
#[clap(about = "Tauri dev", trailing_var_arg(true))]
pub struct Options {
/// Binary to use to run the application
#[clap(short, long)]
Expand Down
23 changes: 14 additions & 9 deletions tooling/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod interface;
mod plugin;
mod signer;

use clap::{AppSettings, FromArgMatches, IntoApp, Parser, Subcommand};
use clap::{FromArgMatches, IntoApp, Parser, Subcommand};

use std::ffi::OsString;

Expand All @@ -37,11 +37,16 @@ pub struct VersionMetadata {
}

#[derive(Parser)]
#[clap(author, version, about, bin_name("cargo-tauri"))]
#[clap(global_setting(AppSettings::PropagateVersion))]
#[clap(global_setting(AppSettings::UseLongFormatForHelpSubcommand))]
#[clap(global_setting(AppSettings::NoBinaryName))]
#[clap(setting(AppSettings::SubcommandRequiredElseHelp))]
#[clap(
author,
version,
about,
bin_name("cargo-tauri"),
subcommand_required(true),
arg_required_else_help(true),
propagate_version(true),
no_binary_name(true)
)]
struct Cli {
#[clap(subcommand)]
command: Commands,
Expand All @@ -58,7 +63,7 @@ enum Commands {
}

fn format_error<I: IntoApp>(err: clap::Error) -> clap::Error {
let mut app = I::into_app();
let mut app = I::command();
err.format(&mut app)
}

Expand All @@ -80,8 +85,8 @@ where
A: Into<OsString> + Clone,
{
let matches = match bin_name {
Some(bin_name) => Cli::into_app().bin_name(bin_name),
None => Cli::into_app(),
Some(bin_name) => Cli::command().bin_name(bin_name),
None => Cli::command(),
}
.get_matches_from(args);

Expand Down
6 changes: 4 additions & 2 deletions tooling/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::path::Path;
use std::process::exit;

fn main() -> tauri_cli::Result<()> {
let mut args = args_os();
let mut args = args_os().peekable();
let bin_name = match args
.next()
.as_deref()
Expand All @@ -17,7 +17,9 @@ fn main() -> tauri_cli::Result<()> {
.and_then(OsStr::to_str)
{
Some("cargo-tauri") => {
if args.by_ref().peekable().peek().and_then(|s| s.to_str()) == Some("tauri") {
if args.peek().and_then(|s| s.to_str()) == Some("tauri") {
// remove the extra cargo subcommand
args.next();
Some("cargo tauri".into())
} else {
Some("cargo-tauri".into())
Expand Down
11 changes: 8 additions & 3 deletions tooling/cli/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use clap::{AppSettings, Parser, Subcommand};
use clap::{Parser, Subcommand};

use crate::Result;

mod init;

#[derive(Parser)]
#[clap(author, version, about = "Manage Tauri plugins")]
#[clap(setting(AppSettings::SubcommandRequiredElseHelp))]
#[clap(
author,
version,
about = "Manage Tauri plugins",
subcommand_required(true),
arg_required_else_help(true)
)]
pub struct Cli {
#[clap(subcommand)]
command: Commands,
Expand Down
3 changes: 1 addition & 2 deletions tooling/cli/src/plugin/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
VersionMetadata,
};
use anyhow::Context;
use clap::{ArgSettings, Parser};
use clap::Parser;
use handlebars::{to_json, Handlebars};
use heck::{ToKebabCase, ToSnakeCase};
use include_dir::{include_dir, Dir};
Expand All @@ -28,7 +28,6 @@ pub struct Options {
api: bool,
/// Initializes a Tauri core plugin (internal usage)
#[clap(long, hide(true))]
#[clap(setting(ArgSettings::Hidden))]
tauri: bool,
/// Set target directory for init
#[clap(short, long)]
Expand Down

0 comments on commit b10a7cf

Please sign in to comment.