Browse Source

fix(deps): update rust crate clap to v3 (#617)

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
remotes/origin/feat/support-install-latest
renovate[bot] 3 years ago committed by GitHub
parent
commit
b6b0cfa0e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .ci/print-command-docs.js
  2. 105
      Cargo.lock
  3. 4
      Cargo.toml
  4. 807
      docs/commands.md
  5. 38
      src/cli.rs
  6. 3
      src/commands/alias.rs
  7. 11
      src/commands/completions.rs
  8. 3
      src/commands/current.rs
  9. 3
      src/commands/default.rs
  10. 11
      src/commands/env.rs
  11. 9
      src/commands/exec.rs
  12. 5
      src/commands/install.rs
  13. 3
      src/commands/ls_local.rs
  14. 3
      src/commands/ls_remote.rs
  15. 3
      src/commands/unalias.rs
  16. 3
      src/commands/uninstall.rs
  17. 7
      src/commands/use.rs
  18. 22
      src/config.rs
  19. 4
      src/shell/bash.rs
  20. 4
      src/shell/fish.rs
  21. 4
      src/shell/powershell.rs
  22. 6
      src/shell/shell.rs
  23. 3
      src/shell/windows_cmd/mod.rs
  24. 4
      src/shell/zsh.rs

6
.ci/print-command-docs.js

@ -112,8 +112,10 @@ async function getCommandHelp(fnmPath, command) { @@ -112,8 +112,10 @@ async function getCommandHelp(fnmPath, command) {
const subcommands = [];
if (!command) {
for (const row of rows.slice(headerIndex + 1)) {
const words = row.split(/\s+/);
subcommands.push(words[1]);
const [, word] = row.split(/\s+/);
if (word && word[0].toLowerCase() === word[0]) {
subcommands.push(word);
}
}
}
return {

105
Cargo.lock generated

@ -207,17 +207,41 @@ dependencies = [ @@ -207,17 +207,41 @@ dependencies = [
[[package]]
name = "clap"
version = "2.34.0"
version = "3.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
checksum = "f6f34b09b9ee8c7c7b400fe2f8df39cafc9538b03d6ba7f4ae13e4cb90bfbb7d"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"clap_derive",
"indexmap",
"lazy_static",
"os_str_bytes",
"strsim",
"termcolor",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "clap_complete"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a394f7ec0715b42a4e52b294984c27c9a61f77c8d82f7774c5198350be143f19"
dependencies = [
"clap",
]
[[package]]
name = "clap_derive"
version = "3.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41a0645a430ec9136d2d701e54a95d557de12649a9dd7109ced3187e648ac824"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -483,6 +507,7 @@ dependencies = [ @@ -483,6 +507,7 @@ dependencies = [
"atty",
"chrono",
"clap",
"clap_complete",
"colored",
"csv",
"dirs",
@ -501,7 +526,6 @@ dependencies = [ @@ -501,7 +526,6 @@ dependencies = [
"serde_json",
"serial_test",
"shell-escape",
"structopt",
"sysinfo",
"tar",
"tempfile",
@ -620,12 +644,9 @@ checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" @@ -620,12 +644,9 @@ checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
[[package]]
name = "heck"
version = "0.3.3"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
dependencies = [
"unicode-segmentation",
]
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
[[package]]
name = "hermit-abi"
@ -980,6 +1001,15 @@ dependencies = [ @@ -980,6 +1001,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "os_str_bytes"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
dependencies = [
"memchr",
]
[[package]]
name = "output_vt100"
version = "0.1.2"
@ -1452,33 +1482,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" @@ -1452,33 +1482,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "structopt"
version = "0.3.25"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c"
dependencies = [
"clap",
"lazy_static",
"structopt-derive",
]
[[package]]
name = "structopt-derive"
version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
@ -1563,12 +1569,9 @@ dependencies = [ @@ -1563,12 +1569,9 @@ dependencies = [
[[package]]
name = "textwrap"
version = "0.11.0"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
[[package]]
name = "thiserror"
@ -1704,18 +1707,6 @@ dependencies = [ @@ -1704,18 +1707,6 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-segmentation"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "unicode-xid"
version = "0.2.2"
@ -1752,12 +1743,6 @@ version = "0.8.2" @@ -1752,12 +1743,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.3"

4
Cargo.toml

@ -10,8 +10,7 @@ description = "Fast and simple Node.js version manager" @@ -10,8 +10,7 @@ description = "Fast and simple Node.js version manager"
[dependencies]
serde = { version = "1.0.133", features = ["derive"] }
clap = "2.34.0"
structopt = "0.3.25"
clap = { version = "3.0.5", features = ["derive", "env"] }
serde_json = "1.0.74"
chrono = { version = "0.4.19", features = ["serde"] }
tar = "0.4.38"
@ -30,6 +29,7 @@ reqwest = { version = "0.11.8", features = ["blocking", "json", "rustls-tls", "r @@ -30,6 +29,7 @@ reqwest = { version = "0.11.8", features = ["blocking", "json", "rustls-tls", "r
url = "2.2.2"
sysinfo = "0.22.5"
thiserror = "1.0.30"
clap_complete = "3.0.2"
[dev-dependencies]
pretty_assertions = "1.0.0"

807
docs/commands.md

File diff suppressed because it is too large Load Diff

38
src/cli.rs

@ -1,24 +1,24 @@ @@ -1,24 +1,24 @@
use crate::commands;
use crate::commands::command::Command;
use crate::config::FnmConfig;
use structopt::StructOpt;
use clap::Parser;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub enum SubCommand {
/// List all remote Node.js versions
#[structopt(name = "list-remote", visible_aliases = &["ls-remote"])]
#[clap(name = "list-remote", visible_aliases = &["ls-remote"])]
LsRemote(commands::ls_remote::LsRemote),
/// List all locally installed Node.js versions
#[structopt(name = "list", visible_aliases = &["ls"])]
#[clap(name = "list", visible_aliases = &["ls"])]
LsLocal(commands::ls_local::LsLocal),
/// Install a new Node.js version
#[structopt(name = "install")]
#[clap(name = "install")]
Install(commands::install::Install),
/// Change Node.js version
#[structopt(name = "use")]
#[clap(name = "use")]
Use(commands::r#use::Use),
/// Print and set up required environment variables for fnm
@ -29,29 +29,29 @@ pub enum SubCommand { @@ -29,29 +29,29 @@ pub enum SubCommand {
/// Each shell has its own syntax of evaluating a dynamic expression.
/// For example, evaluating fnm on Bash and Zsh would look like `eval "$(fnm env)"`.
/// In Fish, evaluating would look like `fnm env | source`
#[structopt(name = "env")]
#[clap(name = "env")]
Env(commands::env::Env),
/// Print shell completions to stdout
#[structopt(name = "completions")]
#[clap(name = "completions")]
Completions(commands::completions::Completions),
/// Alias a version to a common name
#[structopt(name = "alias")]
#[clap(name = "alias")]
Alias(commands::alias::Alias),
/// Remove an alias definition
#[structopt(name = "unalias")]
#[clap(name = "unalias")]
Unalias(commands::unalias::Unalias),
/// Set a version as the default version
///
/// This is a shorthand for `fnm alias VERSION default`
#[structopt(name = "default")]
#[clap(name = "default")]
Default(commands::default::Default),
/// Print the current Node.js version
#[structopt(name = "current")]
#[clap(name = "current")]
Current(commands::current::Current),
/// Run a command within fnm context
@ -60,14 +60,14 @@ pub enum SubCommand { @@ -60,14 +60,14 @@ pub enum SubCommand {
/// --------
/// fnm exec --using=v12.0.0 node --version
/// => v12.0.0
#[structopt(name = "exec", verbatim_doc_comment)]
#[clap(name = "exec", verbatim_doc_comment)]
Exec(commands::exec::Exec),
/// Uninstall a Node.js version
///
/// > Warning: when providing an alias, it will remove the Node version the alias
/// is pointing to, along with the other aliases that point to the same version.
#[structopt(name = "uninstall")]
#[clap(name = "uninstall")]
Uninstall(commands::uninstall::Uninstall),
}
@ -91,15 +91,15 @@ impl SubCommand { @@ -91,15 +91,15 @@ impl SubCommand {
}
/// A fast and simple Node.js manager.
#[derive(StructOpt, Debug)]
#[structopt(name = "fnm")]
#[derive(clap::Parser, Debug)]
#[clap(name = "fnm", version = env!("CARGO_PKG_VERSION"))]
pub struct Cli {
#[structopt(flatten)]
#[clap(flatten)]
pub config: FnmConfig,
#[structopt(subcommand)]
#[clap(subcommand)]
pub subcmd: SubCommand,
}
pub fn parse() -> Cli {
Cli::from_args()
Cli::parse()
}

3
src/commands/alias.rs

@ -5,10 +5,9 @@ use crate::choose_version_for_user_input::{ @@ -5,10 +5,9 @@ use crate::choose_version_for_user_input::{
};
use crate::config::FnmConfig;
use crate::user_version::UserVersion;
use structopt::StructOpt;
use thiserror::Error;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub struct Alias {
pub(crate) to_version: UserVersion,
pub(crate) name: String,

11
src/commands/completions.rs

@ -2,14 +2,14 @@ use super::command::Command; @@ -2,14 +2,14 @@ use super::command::Command;
use crate::cli::Cli;
use crate::config::FnmConfig;
use crate::shell::{infer_shell, AVAILABLE_SHELLS};
use structopt::clap::Shell;
use structopt::StructOpt;
use clap::{IntoApp, Parser};
use clap_complete::{Generator, Shell};
use thiserror::Error;
#[derive(StructOpt, Debug)]
#[derive(Parser, Debug)]
pub struct Completions {
/// The shell syntax to use. Infers when missing.
#[structopt(long, possible_values = &Shell::variants())]
#[clap(long)]
shell: Option<Shell>,
}
@ -22,7 +22,8 @@ impl Command for Completions { @@ -22,7 +22,8 @@ impl Command for Completions {
.shell
.or_else(|| infer_shell().map(Into::into))
.ok_or(Error::CantInferShell)?;
Cli::clap().gen_completions_to(env!("CARGO_PKG_NAME"), shell, &mut stdio);
let app = Cli::into_app();
shell.generate(&app, &mut stdio);
Ok(())
}
}

3
src/commands/current.rs

@ -1,9 +1,8 @@ @@ -1,9 +1,8 @@
use super::command::Command;
use crate::config::FnmConfig;
use crate::current_version::{current_version, Error};
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub struct Current {}
impl Command for Current {

3
src/commands/default.rs

@ -2,9 +2,8 @@ use super::alias::Alias; @@ -2,9 +2,8 @@ use super::alias::Alias;
use super::command::Command;
use crate::config::FnmConfig;
use crate::user_version::UserVersion;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub struct Default {
version: UserVersion,
}

11
src/commands/env.rs

@ -6,20 +6,19 @@ use crate::path_ext::PathExt; @@ -6,20 +6,19 @@ use crate::path_ext::PathExt;
use crate::shell::{infer_shell, Shell, AVAILABLE_SHELLS};
use colored::Colorize;
use std::fmt::Debug;
use structopt::StructOpt;
use thiserror::Error;
#[derive(StructOpt, Debug, Default)]
#[derive(clap::Parser, Debug, Default)]
pub struct Env {
/// The shell syntax to use. Infers when missing.
#[structopt(long)]
#[structopt(possible_values = AVAILABLE_SHELLS)]
#[clap(long)]
#[clap(possible_values = AVAILABLE_SHELLS)]
shell: Option<Box<dyn Shell>>,
/// Deprecated. This is the default now.
#[structopt(long, hidden = true)]
#[clap(long, hide = true)]
multi: bool,
/// Print the script to change Node versions every directory change
#[structopt(long)]
#[clap(long)]
use_on_cd: bool,
}

9
src/commands/exec.rs

@ -8,17 +8,16 @@ use crate::user_version::UserVersion; @@ -8,17 +8,16 @@ use crate::user_version::UserVersion;
use crate::user_version_reader::UserVersionReader;
use colored::Colorize;
use std::process::{Command, Stdio};
use structopt::StructOpt;
use thiserror::Error;
#[derive(Debug, StructOpt)]
#[structopt(setting = structopt::clap::AppSettings::TrailingVarArg)]
#[derive(Debug, clap::Parser)]
#[clap(setting = clap::AppSettings::TrailingVarArg)]
pub struct Exec {
/// Either an explicit version, or a filename with the version written in it
#[structopt(long = "using")]
#[clap(long = "using")]
version: Option<UserVersionReader>,
/// Deprecated. This is the default now.
#[structopt(long = "using-file", hidden = true)]
#[clap(long = "using-file", hide = true)]
using_file: bool,
/// The command to run
arguments: Vec<String>,

5
src/commands/install.rs

@ -10,16 +10,15 @@ use crate::version::Version; @@ -10,16 +10,15 @@ use crate::version::Version;
use crate::version_files::get_user_version_for_directory;
use colored::Colorize;
use log::debug;
use structopt::StructOpt;
use thiserror::Error;
#[derive(StructOpt, Debug, Default)]
#[derive(clap::Parser, Debug, Default)]
pub struct Install {
/// A version string. Can be a partial semver or a LTS version name by the format lts/NAME
pub version: Option<UserVersion>,
/// Install latest LTS
#[structopt(long, conflicts_with = "version")]
#[clap(long, conflicts_with = "version")]
pub lts: bool,
}

3
src/commands/ls_local.rs

@ -4,10 +4,9 @@ use crate::current_version::current_version; @@ -4,10 +4,9 @@ use crate::current_version::current_version;
use crate::version::Version;
use colored::Colorize;
use std::collections::HashMap;
use structopt::StructOpt;
use thiserror::Error;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub struct LsLocal {}
impl super::command::Command for LsLocal {

3
src/commands/ls_remote.rs

@ -1,9 +1,8 @@ @@ -1,9 +1,8 @@
use crate::config::FnmConfig;
use crate::remote_node_index;
use structopt::StructOpt;
use thiserror::Error;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub struct LsRemote {}
impl super::command::Command for LsRemote {

3
src/commands/unalias.rs

@ -3,10 +3,9 @@ use crate::fs::remove_symlink_dir; @@ -3,10 +3,9 @@ use crate::fs::remove_symlink_dir;
use crate::user_version::UserVersion;
use crate::version::Version;
use crate::{choose_version_for_user_input, config::FnmConfig};
use structopt::StructOpt;
use thiserror::Error;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub struct Unalias {
pub(crate) requested_alias: String,
}

3
src/commands/uninstall.rs

@ -8,10 +8,9 @@ use crate::version::Version; @@ -8,10 +8,9 @@ use crate::version::Version;
use crate::version_files::get_user_version_for_directory;
use colored::Colorize;
use log::debug;
use structopt::StructOpt;
use thiserror::Error;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub struct Uninstall {
version: Option<UserVersion>,
}

7
src/commands/use.rs

@ -11,19 +11,18 @@ use crate::version_file_strategy::VersionFileStrategy; @@ -11,19 +11,18 @@ use crate::version_file_strategy::VersionFileStrategy;
use crate::{config::FnmConfig, user_version_reader::UserVersionReader};
use colored::Colorize;
use std::path::Path;
use structopt::StructOpt;
use thiserror::Error;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub struct Use {
version: Option<UserVersionReader>,
/// Install the version if it isn't installed yet
#[structopt(long)]
#[clap(long)]
install_if_missing: bool,
/// Don't output a message identifying the version being used
/// if it will not change due to execution of this command
#[structopt(long)]
#[clap(long)]
silent_if_unchanged: bool,
}

22
src/config.rs

@ -3,13 +3,12 @@ use crate::log_level::LogLevel; @@ -3,13 +3,12 @@ use crate::log_level::LogLevel;
use crate::path_ext::PathExt;
use crate::version_file_strategy::VersionFileStrategy;
use dirs::{data_dir, home_dir};
use structopt::StructOpt;
use url::Url;
#[derive(StructOpt, Debug)]
#[derive(clap::Parser, Debug)]
pub struct FnmConfig {
/// https://nodejs.org/dist/ mirror
#[structopt(
#[clap(
long,
env = "FNM_NODE_DIST_MIRROR",
default_value = "https://nodejs.org/dist",
@ -19,7 +18,7 @@ pub struct FnmConfig { @@ -19,7 +18,7 @@ pub struct FnmConfig {
pub node_dist_mirror: Url,
/// The root directory of fnm installations.
#[structopt(
#[clap(
long = "fnm-dir",
env = "FNM_DIR",
global = true,
@ -30,16 +29,11 @@ pub struct FnmConfig { @@ -30,16 +29,11 @@ pub struct FnmConfig {
/// Where the current node version link is stored.
/// This value will be populated automatically by evaluating
/// `fnm env` in your shell profile. Read more about it using `fnm help env`
#[structopt(
long,
env = "FNM_MULTISHELL_PATH",
hide_env_values = true,
hidden = true
)]
#[clap(long, env = "FNM_MULTISHELL_PATH", hide_env_values = true, hide = true)]
multishell_path: Option<std::path::PathBuf>,
/// The log level of fnm commands
#[structopt(
#[clap(
long,
env = "FNM_LOGLEVEL",
default_value = "info",
@ -51,10 +45,10 @@ pub struct FnmConfig { @@ -51,10 +45,10 @@ pub struct FnmConfig {
/// Override the architecture of the installed Node binary.
/// Defaults to arch of fnm binary.
#[structopt(
#[clap(
long,
env = "FNM_ARCH",
default_value,
default_value_t,
global = true,
hide_env_values = true,
hide_default_value = true
@ -67,7 +61,7 @@ pub struct FnmConfig { @@ -67,7 +61,7 @@ pub struct FnmConfig {
/// * `local`: Use the local version of Node defined within the current directory
///
/// * `recursive`: Use the version of Node defined within the current directory and all parent directories
#[structopt(
#[clap(
long,
env = "FNM_VERSION_FILE_STRATEGY",
possible_values = VersionFileStrategy::possible_values(),

4
src/shell/bash.rs

@ -8,8 +8,8 @@ use std::path::Path; @@ -8,8 +8,8 @@ use std::path::Path;
pub struct Bash;
impl Shell for Bash {
fn to_structopt_shell(&self) -> structopt::clap::Shell {
structopt::clap::Shell::Bash
fn to_clap_shell(&self) -> clap_complete::Shell {
clap_complete::Shell::Bash
}
fn path(&self, path: &Path) -> String {

4
src/shell/fish.rs

@ -8,8 +8,8 @@ use std::path::Path; @@ -8,8 +8,8 @@ use std::path::Path;
pub struct Fish;
impl Shell for Fish {
fn to_structopt_shell(&self) -> structopt::clap::Shell {
structopt::clap::Shell::Fish
fn to_clap_shell(&self) -> clap_complete::Shell {
clap_complete::Shell::Fish
}
fn path(&self, path: &Path) -> String {

4
src/shell/powershell.rs

@ -41,7 +41,7 @@ impl Shell for PowerShell { @@ -41,7 +41,7 @@ impl Shell for PowerShell {
autoload_hook = autoload_hook
)
}
fn to_structopt_shell(&self) -> clap::Shell {
clap::Shell::PowerShell
fn to_clap_shell(&self) -> clap_complete::Shell {
clap_complete::Shell::PowerShell
}
}

6
src/shell/shell.rs

@ -8,7 +8,7 @@ pub trait Shell: Debug { @@ -8,7 +8,7 @@ pub trait Shell: Debug {
fn rehash(&self) -> Option<String> {
None
}
fn to_structopt_shell(&self) -> structopt::clap::Shell;
fn to_clap_shell(&self) -> clap_complete::Shell;
}
#[cfg(windows)]
@ -32,8 +32,8 @@ impl std::str::FromStr for Box<dyn Shell> { @@ -32,8 +32,8 @@ impl std::str::FromStr for Box<dyn Shell> {
}
}
impl From<Box<dyn Shell>> for structopt::clap::Shell {
impl From<Box<dyn Shell>> for clap_complete::Shell {
fn from(shell: Box<dyn Shell>) -> Self {
shell.to_structopt_shell()
shell.to_clap_shell()
}
}

3
src/shell/windows_cmd/mod.rs

@ -5,7 +5,8 @@ use std::path::Path; @@ -5,7 +5,8 @@ use std::path::Path;
pub struct WindowsCmd;
impl Shell for WindowsCmd {
fn to_structopt_shell(&self) -> structopt::clap::Shell {
fn to_clap_shell(&self) -> clap_complete::Shell {
// TODO: move to Option
panic!("Shell completion is not supported for Windows Command Prompt. Maybe try using PowerShell for a better experience?");
}

4
src/shell/zsh.rs

@ -8,8 +8,8 @@ use std::path::Path; @@ -8,8 +8,8 @@ use std::path::Path;
pub struct Zsh;
impl Shell for Zsh {
fn to_structopt_shell(&self) -> structopt::clap::Shell {
structopt::clap::Shell::Zsh
fn to_clap_shell(&self) -> clap_complete::Shell {
clap_complete::Shell::Zsh
}
fn path(&self, path: &Path) -> String {

Loading…
Cancel
Save