From 76bff6f34e676b736839bebba2fb06250ddbfb25 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 1 Aug 2022 09:02:52 -0500 Subject: [PATCH] fix!: Remove rest of deprecated APIs Fixes #4009 --- clap_complete/src/dynamic.rs | 14 ++-- clap_complete/src/generator/utils.rs | 2 +- clap_complete/src/shells/bash.rs | 1 + clap_complete/src/shells/shell.rs | 3 +- clap_complete/src/shells/zsh.rs | 1 + clap_complete/tests/common.rs | 4 +- clap_complete_fig/tests/common.rs | 4 +- clap_derive/src/derives/args.rs | 2 +- clap_derive/src/derives/subcommand.rs | 4 +- clap_derive/src/derives/value_enum.rs | 4 +- clap_derive/src/dummies.rs | 2 +- clap_derive/src/lib.rs | 8 --- clap_mangen/tests/common.rs | 4 +- examples/tutorial_builder/04_04_custom.rs | 3 +- examples/tutorial_derive/04_01_enum.rs | 4 +- examples/tutorial_derive/04_04_custom.rs | 3 +- src/_derive/mod.rs | 16 ++--- src/builder/action.rs | 8 --- src/builder/app_settings.rs | 2 - src/builder/arg.rs | 64 ++++++++--------- src/builder/arg_group.rs | 14 ++-- src/builder/arg_settings.rs | 2 - src/builder/command.rs | 32 ++++----- src/builder/possible_value.rs | 14 ++-- src/builder/value_parser.rs | 52 +++++++------- src/derive.rs | 3 +- src/error/kind.rs | 30 ++++---- src/lib.rs | 7 +- src/macros.rs | 3 - src/output/help.rs | 2 +- src/output/usage.rs | 1 - src/parser/arg_matcher.rs | 6 -- src/parser/matches/arg_matches.rs | 42 ++---------- src/parser/matches/matched_arg.rs | 19 +---- tests/builder/action.rs | 84 ----------------------- tests/builder/app_settings.rs | 1 - tests/builder/default_missing_vals.rs | 18 ++--- tests/builder/help.rs | 2 +- tests/builder/possible_values.rs | 2 +- tests/builder/utf8.rs | 1 - tests/derive/arguments.rs | 2 +- tests/derive/custom_string_parsers.rs | 2 - tests/derive/flags.rs | 2 - tests/derive/non_literal_attributes.rs | 3 +- tests/derive/subcommands.rs | 5 +- tests/derive/type_alias_regressions.rs | 1 - tests/derive/utf8.rs | 3 +- tests/derive/value_enum.rs | 8 +-- tests/macros.rs | 12 ---- 49 files changed, 172 insertions(+), 354 deletions(-) diff --git a/clap_complete/src/dynamic.rs b/clap_complete/src/dynamic.rs index e8f4d584..3bf0088e 100644 --- a/clap_complete/src/dynamic.rs +++ b/clap_complete/src/dynamic.rs @@ -68,7 +68,7 @@ pub mod bash { } /// Process the completion request - pub fn try_complete(&self, cmd: &mut clap::Command) -> clap::Result<()> { + pub fn try_complete(&self, cmd: &mut clap::Command) -> clap::error::Result<()> { debug!("CompleteCommand::try_complete: {:?}", self); let CompleteCommand::Complete(args) = self; if let Some(out_path) = args.register.as_deref() { @@ -231,13 +231,13 @@ complete OPTIONS -F _clap_complete_NAME EXECUTABLES Self::Menu, ] } - fn to_possible_value<'a>(&self) -> ::std::option::Option> { + fn to_possible_value<'a>(&self) -> ::std::option::Option> { match self { Self::Normal => { let value = "9"; debug_assert_eq!(b'\t'.to_string(), value); Some( - clap::PossibleValue::new(value) + clap::builder::PossibleValue::new(value) .alias("normal") .help("Normal completion"), ) @@ -246,7 +246,7 @@ complete OPTIONS -F _clap_complete_NAME EXECUTABLES let value = "63"; debug_assert_eq!(b'?'.to_string(), value); Some( - clap::PossibleValue::new(value) + clap::builder::PossibleValue::new(value) .alias("successive") .help("List completions after successive tabs"), ) @@ -255,7 +255,7 @@ complete OPTIONS -F _clap_complete_NAME EXECUTABLES let value = "33"; debug_assert_eq!(b'!'.to_string(), value); Some( - clap::PossibleValue::new(value) + clap::builder::PossibleValue::new(value) .alias("alternatives") .help("List alternatives on partial word completion"), ) @@ -264,7 +264,7 @@ complete OPTIONS -F _clap_complete_NAME EXECUTABLES let value = "64"; debug_assert_eq!(b'@'.to_string(), value); Some( - clap::PossibleValue::new(value) + clap::builder::PossibleValue::new(value) .alias("unmodified") .help("List completions if the word is not unmodified"), ) @@ -273,7 +273,7 @@ complete OPTIONS -F _clap_complete_NAME EXECUTABLES let value = "37"; debug_assert_eq!(b'%'.to_string(), value); Some( - clap::PossibleValue::new(value) + clap::builder::PossibleValue::new(value) .alias("menu") .help("Menu completion"), ) diff --git a/clap_complete/src/generator/utils.rs b/clap_complete/src/generator/utils.rs index 9364d79b..51a68c6e 100644 --- a/clap_complete/src/generator/utils.rs +++ b/clap_complete/src/generator/utils.rs @@ -127,7 +127,7 @@ pub fn flags<'help>(p: &Command<'help>) -> Vec> { } /// Get the possible values for completion -pub fn possible_values<'help>(a: &Arg<'help>) -> Option>> { +pub fn possible_values<'help>(a: &Arg<'help>) -> Option>> { if !a.is_takes_value_set() { None } else { diff --git a/clap_complete/src/shells/bash.rs b/clap_complete/src/shells/bash.rs index f1a44b40..07c4f704 100644 --- a/clap_complete/src/shells/bash.rs +++ b/clap_complete/src/shells/bash.rs @@ -1,5 +1,6 @@ use std::{fmt::Write as _, io::Write}; +use clap::builder::PossibleValue; use clap::*; use crate::generator::{utils, Generator}; diff --git a/clap_complete/src/shells/shell.rs b/clap_complete/src/shells/shell.rs index b1f7270d..c47f5966 100644 --- a/clap_complete/src/shells/shell.rs +++ b/clap_complete/src/shells/shell.rs @@ -1,7 +1,8 @@ use std::fmt::Display; use std::str::FromStr; -use clap::{PossibleValue, ValueEnum}; +use clap::builder::PossibleValue; +use clap::ValueEnum; use crate::shells; use crate::Generator; diff --git a/clap_complete/src/shells/zsh.rs b/clap_complete/src/shells/zsh.rs index b7129e43..16b47647 100644 --- a/clap_complete/src/shells/zsh.rs +++ b/clap_complete/src/shells/zsh.rs @@ -1,5 +1,6 @@ use std::io::Write; +use clap::builder::PossibleValue; use clap::*; use crate::generator::{utils, Generator}; diff --git a/clap_complete/tests/common.rs b/clap_complete/tests/common.rs index d40fb5f1..13af2fcc 100644 --- a/clap_complete/tests/common.rs +++ b/clap_complete/tests/common.rs @@ -154,7 +154,9 @@ pub fn sub_subcommands_command(name: &'static str) -> clap::Command<'static> { clap::Arg::new("config") .long("config") .action(clap::ArgAction::Set) - .value_parser([clap::PossibleValue::new("Lest quotes aren't escaped.")]) + .value_parser([clap::builder::PossibleValue::new( + "Lest quotes aren't escaped.", + )]) .help("the other case to test"), ), ), diff --git a/clap_complete_fig/tests/common.rs b/clap_complete_fig/tests/common.rs index d40fb5f1..13af2fcc 100644 --- a/clap_complete_fig/tests/common.rs +++ b/clap_complete_fig/tests/common.rs @@ -154,7 +154,9 @@ pub fn sub_subcommands_command(name: &'static str) -> clap::Command<'static> { clap::Arg::new("config") .long("config") .action(clap::ArgAction::Set) - .value_parser([clap::PossibleValue::new("Lest quotes aren't escaped.")]) + .value_parser([clap::builder::PossibleValue::new( + "Lest quotes aren't escaped.", + )]) .help("the other case to test"), ), ), diff --git a/clap_derive/src/derives/args.rs b/clap_derive/src/derives/args.rs index 73d56f6e..81de7a01 100644 --- a/clap_derive/src/derives/args.rs +++ b/clap_derive/src/derives/args.rs @@ -549,7 +549,7 @@ fn gen_parsers( quote_spanned! { ty.span()=> #arg_matches.#get_one(#id) .map(#deref) - .ok_or_else(|| clap::Error::raw(clap::ErrorKind::MissingRequiredArgument, format!("The following required argument was not provided: {}", #id))) + .ok_or_else(|| clap::Error::raw(clap::error::ErrorKind::MissingRequiredArgument, format!("The following required argument was not provided: {}", #id))) .and_then(#parse)? } } diff --git a/clap_derive/src/derives/subcommand.rs b/clap_derive/src/derives/subcommand.rs index eb9c3dcb..3b6fc122 100644 --- a/clap_derive/src/derives/subcommand.rs +++ b/clap_derive/src/derives/subcommand.rs @@ -523,7 +523,7 @@ fn gen_from_arg_matches( }, None => quote! { - ::std::result::Result::Err(clap::Error::raw(clap::ErrorKind::InvalidSubcommand, format!("The subcommand '{}' wasn't recognized", #subcommand_name_var))) + ::std::result::Result::Err(clap::Error::raw(clap::error::ErrorKind::InvalidSubcommand, format!("The subcommand '{}' wasn't recognized", #subcommand_name_var))) }, }; @@ -540,7 +540,7 @@ fn gen_from_arg_matches( #wildcard } else { - ::std::result::Result::Err(clap::Error::raw(clap::ErrorKind::MissingSubcommand, "A subcommand is required but one was not provided.")) + ::std::result::Result::Err(clap::Error::raw(clap::error::ErrorKind::MissingSubcommand, "A subcommand is required but one was not provided.")) } } } diff --git a/clap_derive/src/derives/value_enum.rs b/clap_derive/src/derives/value_enum.rs index b18b665c..7b072622 100644 --- a/clap_derive/src/derives/value_enum.rs +++ b/clap_derive/src/derives/value_enum.rs @@ -90,7 +90,7 @@ fn lits( let name = attrs.cased_name(); Some(( quote_spanned! { variant.span()=> - clap::PossibleValue::new(#name) + clap::builder::PossibleValue::new(#name) #fields }, variant.ident.clone(), @@ -114,7 +114,7 @@ fn gen_to_possible_value(lits: &[(TokenStream, Ident)]) -> TokenStream { let (lit, variant): (Vec, Vec) = lits.iter().cloned().unzip(); quote! { - fn to_possible_value<'a>(&self) -> ::std::option::Option> { + fn to_possible_value<'a>(&self) -> ::std::option::Option> { match self { #(Self::#variant => Some(#lit),)* _ => None diff --git a/clap_derive/src/dummies.rs b/clap_derive/src/dummies.rs index ed163e81..51740c75 100644 --- a/clap_derive/src/dummies.rs +++ b/clap_derive/src/dummies.rs @@ -82,7 +82,7 @@ pub fn value_enum(name: &Ident) { fn from_str(_input: &str, _ignore_case: bool) -> ::std::result::Result { unimplemented!() } - fn to_possible_value<'a>(&self) -> ::std::option::Option>{ + fn to_possible_value<'a>(&self) -> ::std::option::Option>{ unimplemented!() } } diff --git a/clap_derive/src/lib.rs b/clap_derive/src/lib.rs index 86b7628f..20464ab4 100644 --- a/clap_derive/src/lib.rs +++ b/clap_derive/src/lib.rs @@ -36,14 +36,6 @@ pub fn value_enum(input: TokenStream) -> TokenStream { derives::derive_value_enum(&input).into() } -/// Generates the `ValueEnum` impl. -#[proc_macro_derive(ArgEnum, attributes(clap))] -#[proc_macro_error] -pub fn arg_enum(input: TokenStream) -> TokenStream { - let input: DeriveInput = parse_macro_input!(input); - derives::derive_value_enum(&input).into() -} - /// Generates the `Parser` implementation. /// /// This is far less verbose than defining the `clap::Command` struct manually, diff --git a/clap_mangen/tests/common.rs b/clap_mangen/tests/common.rs index 874f1be6..55c5c5fc 100644 --- a/clap_mangen/tests/common.rs +++ b/clap_mangen/tests/common.rs @@ -150,7 +150,9 @@ pub fn sub_subcommands_command(name: &'static str) -> clap::Command<'static> { clap::Arg::new("config") .long("config") .action(clap::ArgAction::Set) - .value_parser([clap::PossibleValue::new("Lest quotes aren't escaped.")]) + .value_parser([clap::builder::PossibleValue::new( + "Lest quotes aren't escaped.", + )]) .help("the other case to test"), ), ), diff --git a/examples/tutorial_builder/04_04_custom.rs b/examples/tutorial_builder/04_04_custom.rs index bd97f7ee..b8b25ee2 100644 --- a/examples/tutorial_builder/04_04_custom.rs +++ b/examples/tutorial_builder/04_04_custom.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; -use clap::{arg, command, value_parser, ArgAction, ErrorKind}; +use clap::error::ErrorKind; +use clap::{arg, command, value_parser, ArgAction}; fn main() { // Create application like normal diff --git a/examples/tutorial_derive/04_01_enum.rs b/examples/tutorial_derive/04_01_enum.rs index 3a2df391..bd23a59b 100644 --- a/examples/tutorial_derive/04_01_enum.rs +++ b/examples/tutorial_derive/04_01_enum.rs @@ -1,4 +1,4 @@ -use clap::{ArgEnum, Parser}; +use clap::{Parser, ValueEnum}; #[derive(Parser)] #[clap(author, version, about, long_about = None)] @@ -8,7 +8,7 @@ struct Cli { mode: Mode, } -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ArgEnum)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] enum Mode { Fast, Slow, diff --git a/examples/tutorial_derive/04_04_custom.rs b/examples/tutorial_derive/04_04_custom.rs index a03345b8..bde8e035 100644 --- a/examples/tutorial_derive/04_04_custom.rs +++ b/examples/tutorial_derive/04_04_custom.rs @@ -1,4 +1,5 @@ -use clap::{CommandFactory, ErrorKind, Parser}; +use clap::error::ErrorKind; +use clap::{CommandFactory, Parser}; #[derive(Parser)] #[clap(author, version, about, long_about = None)] diff --git a/src/_derive/mod.rs b/src/_derive/mod.rs index 43246261..f7a04bcb 100644 --- a/src/_derive/mod.rs +++ b/src/_derive/mod.rs @@ -5,7 +5,7 @@ //! 1. [Terminology](#terminology) //! 2. [Command Attributes](#command-attributes) //! 3. [Arg Attributes](#arg-attributes) -//! 4. [Arg Enum Attributes](#arg-enum-attributes) +//! 4. [ValueEnum Attributes](#valueenum-attributes) //! 5. [Possible Value Attributes](#possible-value-attributes) //! 3. [Arg Types](#arg-types) //! 4. [Doc Comments](#doc-comments) @@ -98,7 +98,7 @@ //! ### Terminology //! //! **Raw attributes** are forwarded directly to the underlying [`clap` builder][crate::builder]. Any -//! [`Command`][crate::Command], [`Arg`][crate::Arg], or [`PossibleValue`][crate::PossibleValue] method can be used as an attribute. +//! [`Command`][crate::Command], [`Arg`][crate::Arg], or [`PossibleValue`][crate::builder::PossibleValue] method can be used as an attribute. //! //! Raw attributes come in two different syntaxes: //! ```rust,ignore @@ -233,23 +233,23 @@ //! - Requires field arg to be of type `Vec` and `T` to implement `std::convert::Into` or `#[clap(value_enum)]` //! - `` must implement `IntoIterator` //! -//! ### Value Enum Attributes +//! ### ValueEnum Attributes //! -//! - `rename_all = `: Override default field / variant name case conversion for [`PossibleValue::new`][crate::PossibleValue] +//! - `rename_all = `: Override default field / variant name case conversion for [`PossibleValue::new`][crate::builder::PossibleValue] //! - When not present: `"kebab-case"` //! - Available values: `"camelCase"`, `"kebab-case"`, `"PascalCase"`, `"SCREAMING_SNAKE_CASE"`, `"snake_case"`, `"lower"`, `"UPPER"`, `"verbatim"` //! //! ### Possible Value Attributes //! -//! These correspond to a [`PossibleValue`][crate::PossibleValue]. +//! These correspond to a [`PossibleValue`][crate::builder::PossibleValue]. //! -//! **Raw attributes:** Any [`PossibleValue` method][crate::PossibleValue] can also be used as an attribute, see [Terminology](#terminology) for syntax. +//! **Raw attributes:** Any [`PossibleValue` method][crate::builder::PossibleValue] can also be used as an attribute, see [Terminology](#terminology) for syntax. //! - e.g. `#[clap(alias("foo"))]` would translate to `pv.alias("foo")` //! //! **Magic attributes**: -//! - `name = `: [`PossibleValue::new`][crate::PossibleValue::new] +//! - `name = `: [`PossibleValue::new`][crate::builder::PossibleValue::new] //! - When not present: case-converted field name is used -//! - `help = `: [`PossibleValue::help`][crate::PossibleValue::help] +//! - `help = `: [`PossibleValue::help`][crate::builder::PossibleValue::help] //! - When not present: [Doc comment summary](#doc-comments) //! //! ## Arg Types diff --git a/src/builder/action.rs b/src/builder/action.rs index 7d011b7c..ff8f92bf 100644 --- a/src/builder/action.rs +++ b/src/builder/action.rs @@ -40,7 +40,6 @@ pub enum ArgAction { /// /// let matches = cmd.try_get_matches_from(["mycmd", "--flag", "value"]).unwrap(); /// assert!(matches.contains_id("flag")); - /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( /// matches.get_many::("flag").unwrap_or_default().map(|v| v.as_str()).collect::>(), /// vec!["value"] @@ -63,7 +62,6 @@ pub enum ArgAction { /// /// let matches = cmd.try_get_matches_from(["mycmd", "--flag", "value1", "--flag", "value2"]).unwrap(); /// assert!(matches.contains_id("flag")); - /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( /// matches.get_many::("flag").unwrap_or_default().map(|v| v.as_str()).collect::>(), /// vec!["value1", "value2"] @@ -91,7 +89,6 @@ pub enum ArgAction { /// /// let matches = cmd.clone().try_get_matches_from(["mycmd", "--flag", "--flag"]).unwrap(); /// assert!(matches.contains_id("flag")); - /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( /// matches.get_one::("flag").copied(), /// Some(true) @@ -99,7 +96,6 @@ pub enum ArgAction { /// /// let matches = cmd.try_get_matches_from(["mycmd"]).unwrap(); /// assert!(matches.contains_id("flag")); - /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( /// matches.get_one::("flag").copied(), /// Some(false) @@ -127,7 +123,6 @@ pub enum ArgAction { /// /// let matches = cmd.clone().try_get_matches_from(["mycmd", "--flag", "--flag"]).unwrap(); /// assert!(matches.contains_id("flag")); - /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( /// matches.get_one::("flag").copied(), /// Some(false) @@ -135,7 +130,6 @@ pub enum ArgAction { /// /// let matches = cmd.try_get_matches_from(["mycmd"]).unwrap(); /// assert!(matches.contains_id("flag")); - /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( /// matches.get_one::("flag").copied(), /// Some(true) @@ -163,7 +157,6 @@ pub enum ArgAction { /// /// let matches = cmd.clone().try_get_matches_from(["mycmd", "--flag", "--flag"]).unwrap(); /// assert!(matches.contains_id("flag")); - /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( /// matches.get_one::("flag").copied(), /// Some(2) @@ -171,7 +164,6 @@ pub enum ArgAction { /// /// let matches = cmd.try_get_matches_from(["mycmd"]).unwrap(); /// assert!(matches.contains_id("flag")); - /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( /// matches.get_one::("flag").copied(), /// Some(0) diff --git a/src/builder/app_settings.rs b/src/builder/app_settings.rs index d733cd54..5af79f46 100644 --- a/src/builder/app_settings.rs +++ b/src/builder/app_settings.rs @@ -1,5 +1,3 @@ -#![allow(deprecated)] - // Std use std::ops::BitOr; diff --git a/src/builder/arg.rs b/src/builder/arg.rs index 6950deff..69f8ed27 100644 --- a/src/builder/arg.rs +++ b/src/builder/arg.rs @@ -1,5 +1,3 @@ -#![allow(deprecated)] - // Std use std::{ borrow::Cow, @@ -14,10 +12,10 @@ use std::{env, ffi::OsString}; // Internal use super::{ArgFlags, ArgSettings}; use crate::builder::ArgPredicate; +use crate::builder::PossibleValue; use crate::builder::ValuesRange; use crate::util::{Id, Key}; use crate::ArgAction; -use crate::PossibleValue; use crate::ValueHint; use crate::INTERNAL_ERROR_MSG; @@ -519,7 +517,7 @@ impl<'help> Arg<'help> { /// failing to use the `--` syntax results in an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("first")) /// .arg(Arg::new("second")) @@ -534,7 +532,7 @@ impl<'help> Arg<'help> { /// assert_eq!(res.unwrap_err().kind(), ErrorKind::UnknownArgument); /// ``` /// [index]: Arg::index() - /// [`UnknownArgument`]: crate::ErrorKind::UnknownArgument + /// [`UnknownArgument`]: crate::error::ErrorKind::UnknownArgument #[inline] #[must_use] pub fn last(self, yes: bool) -> Self { @@ -585,7 +583,7 @@ impl<'help> Arg<'help> { /// Setting required and then *not* supplying that argument at runtime is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required(true) @@ -645,7 +643,7 @@ impl<'help> Arg<'help> { /// Setting [`Arg::requires(name)`] and *not* supplying that argument is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .action(ArgAction::Set) @@ -683,7 +681,7 @@ impl<'help> Arg<'help> { /// is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("exclusive") /// .action(ArgAction::Set) @@ -837,7 +835,6 @@ impl<'help> Arg<'help> { /// /// let matches = cmd.try_get_matches_from(["mycmd", "--flag", "value"]).unwrap(); /// assert!(matches.contains_id("flag")); - /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( /// matches.get_many::("flag").unwrap_or_default().map(|v| v.as_str()).collect::>(), /// vec!["value"] @@ -984,7 +981,7 @@ impl<'help> Arg<'help> { /// Although `multiple_values` has been specified, the last argument still wins /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let m = Command::new("prog") /// .arg(Arg::new("file") /// .action(ArgAction::Set) @@ -1048,7 +1045,7 @@ impl<'help> Arg<'help> { /// As a final example, let's fix the above error and get a pretty message to the user :) /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .action(ArgAction::Set) @@ -1127,7 +1124,7 @@ impl<'help> Arg<'help> { /// /// Flag/option hybrid (see also [default_missing_value][Arg::default_missing_value]) /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let cmd = Command::new("prog") /// .arg(Arg::new("mode") /// .long("mode") @@ -1156,7 +1153,7 @@ impl<'help> Arg<'help> { /// /// Tuples /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let cmd = Command::new("prog") /// .arg(Arg::new("file") /// .action(ArgAction::Set) @@ -1475,7 +1472,7 @@ impl<'help> Arg<'help> { /// hyphen is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("pat") /// .action(ArgAction::Set) @@ -1527,7 +1524,7 @@ impl<'help> Arg<'help> { /// error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .action(ArgAction::Set) @@ -1681,7 +1678,7 @@ impl<'help> Arg<'help> { /// In this next example, we will *not* use a delimiter. Notice it's now an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("opt") /// .short('o') @@ -1814,10 +1811,6 @@ impl<'help> Arg<'help> { /// Value for the argument when not present. /// - /// **NOTE:** If the user *does not* use this argument at runtime, [`ArgMatches::occurrences_of`] - /// will return `0` even though the [`ArgMatches::get_one`][crate::ArgMatches::get_one] will - /// return the default specified. - /// /// **NOTE:** If the user *does not* use this argument at runtime [`ArgMatches::contains_id`] will /// still return `true`. If you wish to determine whether the argument was used at runtime or /// not, consider [`ArgMatches::value_source`][crate::ArgMatches::value_source]. @@ -1837,7 +1830,7 @@ impl<'help> Arg<'help> { /// First we use the default value without providing any value at runtime. /// /// ```rust - /// # use clap::{Command, Arg, ValueSource}; + /// # use clap::{Command, Arg, parser::ValueSource}; /// let m = Command::new("prog") /// .arg(Arg::new("opt") /// .long("myopt") @@ -1854,7 +1847,7 @@ impl<'help> Arg<'help> { /// Next we provide a value at runtime to override the default. /// /// ```rust - /// # use clap::{Command, Arg, ValueSource}; + /// # use clap::{Command, Arg, parser::ValueSource}; /// let m = Command::new("prog") /// .arg(Arg::new("opt") /// .long("myopt") @@ -1867,7 +1860,6 @@ impl<'help> Arg<'help> { /// assert!(m.contains_id("opt")); /// assert_eq!(m.value_source("opt"), Some(ValueSource::CommandLine)); /// ``` - /// [`ArgMatches::occurrences_of`]: crate::ArgMatches::occurrences_of() /// [`Arg::action(ArgAction::Set)`]: Arg::takes_value() /// [`ArgMatches::contains_id`]: crate::ArgMatches::contains_id() /// [`Arg::default_value_if`]: Arg::default_value_if() @@ -1930,7 +1922,7 @@ impl<'help> Arg<'help> { /// /// For POSIX style `--color`: /// ```rust - /// # use clap::{Command, Arg, ValueSource}; + /// # use clap::{Command, Arg, parser::ValueSource}; /// fn cli() -> Command<'static> { /// Command::new("prog") /// .arg(Arg::new("color").long("color") @@ -1968,7 +1960,7 @@ impl<'help> Arg<'help> { /// /// For bool literals: /// ```rust - /// # use clap::{Command, Arg, ValueSource, value_parser}; + /// # use clap::{Command, Arg, parser::ValueSource, value_parser}; /// fn cli() -> Command<'static> { /// Command::new("prog") /// .arg(Arg::new("create").long("create") @@ -3130,7 +3122,7 @@ impl<'help> Arg<'help> { /// Setting `Arg::required_unless_present(name)` and *not* supplying `name` or this arg is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_unless_present("dbg") @@ -3197,7 +3189,7 @@ impl<'help> Arg<'help> { /// either *all* of `unless` args or the `self` arg is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_unless_present_all(&["dbg", "infile"]) @@ -3276,7 +3268,7 @@ impl<'help> Arg<'help> { /// or this arg is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_unless_present_any(&["dbg", "infile"]) @@ -3321,7 +3313,7 @@ impl<'help> Arg<'help> { /// ``` /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .action(ArgAction::Set) @@ -3441,7 +3433,7 @@ impl<'help> Arg<'help> { /// value of `val` but *not* using this arg is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_if_eq_any(&[ @@ -3521,7 +3513,7 @@ impl<'help> Arg<'help> { /// value of `val` but *not* using this arg is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_if_eq_all(&[ @@ -3589,7 +3581,7 @@ impl<'help> Arg<'help> { /// `arg` is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .action(ArgAction::Set) @@ -3634,7 +3626,7 @@ impl<'help> Arg<'help> { /// than `val`, `arg` isn't required. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .action(ArgAction::Set) @@ -3706,7 +3698,7 @@ impl<'help> Arg<'help> { /// error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .action(ArgAction::Set) @@ -3756,7 +3748,7 @@ impl<'help> Arg<'help> { /// Setting conflicting argument, and having both arguments present at runtime is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .action(ArgAction::Set) @@ -3806,7 +3798,7 @@ impl<'help> Arg<'help> { /// conflicting argument is an error. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .action(ArgAction::Set) diff --git a/src/builder/arg_group.rs b/src/builder/arg_group.rs index 02876d3e..17bc9a4c 100644 --- a/src/builder/arg_group.rs +++ b/src/builder/arg_group.rs @@ -34,7 +34,7 @@ use crate::util::{Id, Key}; /// the arguments from the specified group is present at runtime. /// /// ```rust -/// # use clap::{Command, arg, ArgGroup, ErrorKind}; +/// # use clap::{Command, arg, ArgGroup, error::ErrorKind}; /// let result = Command::new("cmd") /// .arg(arg!(--"set-ver" "set the version manually").required(false)) /// .arg(arg!(--major "auto increase major")) @@ -211,7 +211,7 @@ impl<'help> ArgGroup<'help> { /// an error if more than one of the args in the group was used. /// /// ```rust - /// # use clap::{Command, Arg, ArgGroup, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, ArgGroup, error::ErrorKind, ArgAction}; /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f') @@ -252,7 +252,7 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ArgGroup, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, ArgGroup, error::ErrorKind, ArgAction}; /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f') @@ -291,7 +291,7 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ArgGroup, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, ArgGroup, error::ErrorKind, ArgAction}; /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f') @@ -331,7 +331,7 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ArgGroup, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, ArgGroup, error::ErrorKind, ArgAction}; /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f') @@ -376,7 +376,7 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ArgGroup, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, ArgGroup, error::ErrorKind, ArgAction}; /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f') @@ -413,7 +413,7 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ArgGroup, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, ArgGroup, error::ErrorKind, ArgAction}; /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f') diff --git a/src/builder/arg_settings.rs b/src/builder/arg_settings.rs index 87dccd2d..bf30cb57 100644 --- a/src/builder/arg_settings.rs +++ b/src/builder/arg_settings.rs @@ -1,5 +1,3 @@ -#![allow(deprecated)] - // Std use std::ops::BitOr; diff --git a/src/builder/command.rs b/src/builder/command.rs index c78c2bd7..9d25a79f 100644 --- a/src/builder/command.rs +++ b/src/builder/command.rs @@ -1,5 +1,3 @@ -#![allow(deprecated)] - // Std use std::collections::HashMap; use std::env; @@ -13,6 +11,7 @@ use std::path::Path; use crate::builder::app_settings::{AppFlags, AppSettings}; use crate::builder::arg_settings::ArgSettings; use crate::builder::ArgAction; +use crate::builder::PossibleValue; use crate::builder::{arg::ArgProvider, Arg, ArgGroup, ArgPredicate}; use crate::error::ErrorKind; use crate::error::Result as ClapResult; @@ -22,7 +21,6 @@ use crate::output::{fmt::Colorizer, Help, HelpWriter, Usage}; use crate::parser::{ArgMatcher, ArgMatches, Parser}; use crate::util::ChildGraph; use crate::util::{color::ColorChoice, Id, Key}; -use crate::PossibleValue; use crate::{Error, INTERNAL_ERROR_MSG}; #[cfg(debug_assertions)] @@ -495,7 +493,7 @@ impl<'help> Command<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, ErrorKind}; + /// # use clap::{Command, error::ErrorKind}; /// let mut cmd = Command::new("myprog"); /// let err = cmd.error(ErrorKind::InvalidValue, "Some failure case"); /// ``` @@ -574,8 +572,8 @@ impl<'help> Command<'help> { /// [`clap::Result`]: Result /// [`clap::Error`]: crate::Error /// [`kind`]: crate::Error - /// [`ErrorKind::DisplayHelp`]: crate::ErrorKind::DisplayHelp - /// [`ErrorKind::DisplayVersion`]: crate::ErrorKind::DisplayVersion + /// [`ErrorKind::DisplayHelp`]: crate::error::ErrorKind::DisplayHelp + /// [`ErrorKind::DisplayVersion`]: crate::error::ErrorKind::DisplayVersion #[inline] pub fn try_get_matches(self) -> ClapResult { // Start the parsing @@ -647,8 +645,8 @@ impl<'help> Command<'help> { /// [`clap::Error`]: crate::Error /// [`Error::exit`]: crate::Error::exit() /// [`kind`]: crate::Error - /// [`ErrorKind::DisplayHelp`]: crate::ErrorKind::DisplayHelp - /// [`ErrorKind::DisplayVersion`]: crate::ErrorKind::DisplayVersion + /// [`ErrorKind::DisplayHelp`]: crate::error::ErrorKind::DisplayHelp + /// [`ErrorKind::DisplayVersion`]: crate::error::ErrorKind::DisplayVersion /// [`clap::Result`]: Result pub fn try_get_matches_from(mut self, itr: I) -> ClapResult where @@ -958,7 +956,7 @@ impl<'help> Command<'help> { /// assert!(r.is_ok(), "unexpected error: {:?}", r); /// let m = r.unwrap(); /// assert_eq!(m.get_one::("config").unwrap(), "file"); - /// assert!(m.is_present("f")); + /// assert!(*m.get_one::("f").expect("defaulted")); /// assert_eq!(m.get_one::("stuff"), None); /// ``` #[inline] @@ -1081,7 +1079,7 @@ impl<'help> Command<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, ErrorKind}; + /// # use clap::{Command, error::ErrorKind}; /// let res = Command::new("myprog") /// .disable_version_flag(true) /// .try_get_matches_from(vec![ @@ -1159,7 +1157,7 @@ impl<'help> Command<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, ErrorKind}; + /// # use clap::{Command, error::ErrorKind}; /// let res = Command::new("myprog") /// .disable_help_flag(true) /// .try_get_matches_from(vec![ @@ -1182,7 +1180,7 @@ impl<'help> Command<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, ErrorKind}; + /// # use clap::{Command, error::ErrorKind}; /// let res = Command::new("myprog") /// .disable_help_subcommand(true) /// // Normally, creating a subcommand causes a `help` subcommand to automatically @@ -2642,7 +2640,7 @@ impl<'help> Command<'help> { /// # Examples /// /// ```rust - /// # use clap::{Command, ErrorKind}; + /// # use clap::{Command, error::ErrorKind}; /// let err = Command::new("myprog") /// .subcommand_required(true) /// .subcommand(Command::new("test")) @@ -2701,7 +2699,7 @@ impl<'help> Command<'help> { /// /// [`subcommand`]: crate::Command::subcommand() /// [`ArgMatches`]: crate::ArgMatches - /// [`ErrorKind::UnknownArgument`]: crate::ErrorKind::UnknownArgument + /// [`ErrorKind::UnknownArgument`]: crate::error::ErrorKind::UnknownArgument pub fn allow_external_subcommands(self, yes: bool) -> Self { if yes { self.setting(AppSettings::AllowExternalSubcommands) @@ -2880,7 +2878,7 @@ impl<'help> Command<'help> { /// This first example shows that it is an error to not use a required argument /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind}; + /// # use clap::{Command, Arg, error::ErrorKind}; /// let err = Command::new("myprog") /// .subcommand_negates_reqs(true) /// .arg(Arg::new("opt").required(true)) @@ -2897,7 +2895,7 @@ impl<'help> Command<'help> { /// valid subcommand is used. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind}; + /// # use clap::{Command, Arg, error::ErrorKind}; /// let noerr = Command::new("myprog") /// .subcommand_negates_reqs(true) /// .arg(Arg::new("opt").required(true)) @@ -2981,7 +2979,7 @@ impl<'help> Command<'help> { /// This does not allow the subcommand to be passed as the first non-path argument. /// /// ```rust - /// # use clap::{Command, ErrorKind}; + /// # use clap::{Command, error::ErrorKind}; /// let mut cmd = Command::new("hostname") /// .multicall(true) /// .subcommand(Command::new("hostname")) diff --git a/src/builder/possible_value.rs b/src/builder/possible_value.rs index 79787534..7850b663 100644 --- a/src/builder/possible_value.rs +++ b/src/builder/possible_value.rs @@ -12,7 +12,7 @@ use crate::util::eq_ignore_case; /// # Examples /// /// ```rust -/// # use clap::{Arg, PossibleValue, ArgAction}; +/// # use clap::{Arg, builder::PossibleValue, ArgAction}; /// let cfg = Arg::new("config") /// .action(ArgAction::Set) /// .value_name("FILE") @@ -45,7 +45,7 @@ impl<'help> PossibleValue<'help> { /// # Examples /// /// ```rust - /// # use clap::PossibleValue; + /// # use clap::builder::PossibleValue; /// PossibleValue::new("fast") /// # ; /// ``` @@ -67,7 +67,7 @@ impl<'help> PossibleValue<'help> { /// # Examples /// /// ```rust - /// # use clap::PossibleValue; + /// # use clap::builder::PossibleValue; /// PossibleValue::new("slow") /// .help("not fast") /// # ; @@ -87,7 +87,7 @@ impl<'help> PossibleValue<'help> { /// # Examples /// /// ```rust - /// # use clap::PossibleValue; + /// # use clap::builder::PossibleValue; /// PossibleValue::new("secret") /// .hide(true) /// # ; @@ -105,7 +105,7 @@ impl<'help> PossibleValue<'help> { /// # Examples /// /// ```rust - /// # use clap::PossibleValue; + /// # use clap::builder::PossibleValue; /// PossibleValue::new("slow") /// .alias("not-fast") /// # ; @@ -121,7 +121,7 @@ impl<'help> PossibleValue<'help> { /// # Examples /// /// ```rust - /// # use clap::PossibleValue; + /// # use clap::builder::PossibleValue; /// PossibleValue::new("slow") /// .aliases(["not-fast", "snake-like"]) /// # ; @@ -200,7 +200,7 @@ impl<'help> PossibleValue<'help> { /// # Examples /// /// ```rust - /// # use clap::PossibleValue; + /// # use clap::builder::PossibleValue; /// let arg_value = PossibleValue::new("fast").alias("not-slow"); /// /// assert!(arg_value.matches("fast", false)); diff --git a/src/builder/value_parser.rs b/src/builder/value_parser.rs index 4cdc7c1a..bfe03fa4 100644 --- a/src/builder/value_parser.rs +++ b/src/builder/value_parser.rs @@ -244,7 +244,7 @@ impl ValueParser { /// applications like errors and completion. pub fn possible_values( &self, - ) -> Option> + '_>> { + ) -> Option> + '_>> { self.any_value_parser().possible_values() } @@ -480,7 +480,7 @@ impl From for ValueParser { /// Create a [`ValueParser`] with [`PossibleValuesParser`] /// /// See [`PossibleValuesParser`] for more flexibility in creating the -/// [`PossibleValue`][crate::PossibleValue]s. +/// [`PossibleValue`][crate::builder::PossibleValue]s. /// /// # Examples /// @@ -556,7 +556,7 @@ trait AnyValueParser: Send + Sync + 'static { fn possible_values( &self, - ) -> Option> + '_>>; + ) -> Option> + '_>>; fn clone_any(&self) -> Box; } @@ -592,7 +592,7 @@ where fn possible_values( &self, - ) -> Option> + '_>> { + ) -> Option> + '_>> { P::possible_values(self) } @@ -634,7 +634,7 @@ pub trait TypedValueParser: Clone + Send + Sync + 'static { /// applications like errors and completion. fn possible_values( &self, - ) -> Option> + '_>> { + ) -> Option> + '_>> { None } } @@ -833,11 +833,11 @@ impl Default for PathBufValueParser { /// &[Self::Always, Self::Auto, Self::Never] /// } /// -/// fn to_possible_value<'a>(&self) -> Option> { +/// fn to_possible_value<'a>(&self) -> Option> { /// match self { -/// Self::Always => Some(clap::PossibleValue::new("always")), -/// Self::Auto => Some(clap::PossibleValue::new("auto")), -/// Self::Never => Some(clap::PossibleValue::new("never")), +/// Self::Always => Some(clap::builder::PossibleValue::new("always")), +/// Self::Auto => Some(clap::builder::PossibleValue::new("auto")), +/// Self::Never => Some(clap::builder::PossibleValue::new("never")), /// } /// } /// } @@ -928,7 +928,7 @@ impl TypedValueParser for E fn possible_values( &self, - ) -> Option> + '_>> { + ) -> Option> + '_>> { Some(Box::new( E::value_variants() .iter() @@ -943,7 +943,7 @@ impl Default for EnumValueP } } -/// Verify the value is from an enumerated set of [`PossibleValue`][crate::PossibleValue]. +/// Verify the value is from an enumerated set of [`PossibleValue`][crate::builder::PossibleValue]. /// /// See also: /// - [`EnumValueParser`] @@ -982,7 +982,7 @@ impl Default for EnumValueP pub struct PossibleValuesParser(Vec>); impl PossibleValuesParser { - /// Verify the value is from an enumerated set pf [`PossibleValue`][crate::PossibleValue]. + /// Verify the value is from an enumerated set pf [`PossibleValue`][crate::builder::PossibleValue]. pub fn new(values: impl Into) -> Self { values.into() } @@ -1036,7 +1036,7 @@ impl TypedValueParser for PossibleValuesParser { fn possible_values( &self, - ) -> Option> + '_>> { + ) -> Option> + '_>> { Some(Box::new(self.0.iter().cloned())) } } @@ -1458,11 +1458,11 @@ impl BoolValueParser { Self {} } - fn possible_values() -> impl Iterator> { + fn possible_values() -> impl Iterator> { ["true", "false"] .iter() .copied() - .map(crate::PossibleValue::new) + .map(crate::builder::PossibleValue::new) } } @@ -1498,7 +1498,7 @@ impl TypedValueParser for BoolValueParser { fn possible_values( &self, - ) -> Option> + '_>> { + ) -> Option> + '_>> { Some(Box::new(Self::possible_values())) } } @@ -1557,12 +1557,12 @@ impl FalseyValueParser { Self {} } - fn possible_values() -> impl Iterator> { + fn possible_values() -> impl Iterator> { crate::util::TRUE_LITERALS .iter() .chain(crate::util::FALSE_LITERALS.iter()) .copied() - .map(|l| crate::PossibleValue::new(l).hide(l != "true" && l != "false")) + .map(|l| crate::builder::PossibleValue::new(l).hide(l != "true" && l != "false")) } } @@ -1591,7 +1591,7 @@ impl TypedValueParser for FalseyValueParser { fn possible_values( &self, - ) -> Option> + '_>> { + ) -> Option> + '_>> { Some(Box::new(Self::possible_values())) } } @@ -1654,12 +1654,12 @@ impl BoolishValueParser { Self {} } - fn possible_values() -> impl Iterator> { + fn possible_values() -> impl Iterator> { crate::util::TRUE_LITERALS .iter() .chain(crate::util::FALSE_LITERALS.iter()) .copied() - .map(|l| crate::PossibleValue::new(l).hide(l != "true" && l != "false")) + .map(|l| crate::builder::PossibleValue::new(l).hide(l != "true" && l != "false")) } } @@ -1690,7 +1690,7 @@ impl TypedValueParser for BoolishValueParser { fn possible_values( &self, - ) -> Option> + '_>> { + ) -> Option> + '_>> { Some(Box::new(Self::possible_values())) } } @@ -2028,11 +2028,11 @@ pub mod via_prelude { /// # fn value_variants<'a>() -> &'a [Self] { /// # &[Self::Always, Self::Auto, Self::Never] /// # } -/// # fn to_possible_value<'a>(&self) -> Option> { +/// # fn to_possible_value<'a>(&self) -> Option> { /// # match self { -/// # Self::Always => Some(clap::PossibleValue::new("always")), -/// # Self::Auto => Some(clap::PossibleValue::new("auto")), -/// # Self::Never => Some(clap::PossibleValue::new("never")), +/// # Self::Always => Some(clap::builder::PossibleValue::new("always")), +/// # Self::Auto => Some(clap::builder::PossibleValue::new("auto")), +/// # Self::Never => Some(clap::builder::PossibleValue::new("never")), /// # } /// # } /// } diff --git a/src/derive.rs b/src/derive.rs index 7263f078..dedfd30b 100644 --- a/src/derive.rs +++ b/src/derive.rs @@ -1,7 +1,8 @@ //! This module contains traits that are usable with the `#[derive(...)].` //! macros in [`clap_derive`]. -use crate::{ArgMatches, Command, Error, PossibleValue}; +use crate::builder::PossibleValue; +use crate::{ArgMatches, Command, Error}; use std::ffi::OsString; diff --git a/src/error/kind.rs b/src/error/kind.rs index d0ce745c..ac6efb2b 100644 --- a/src/error/kind.rs +++ b/src/error/kind.rs @@ -8,7 +8,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind}; + /// # use clap::{Command, Arg, error::ErrorKind}; /// let result = Command::new("prog") /// .arg(Arg::new("speed") /// .value_parser(["fast", "slow"])) @@ -23,7 +23,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, arg, ErrorKind}; + /// # use clap::{Command, arg, error::ErrorKind}; /// let result = Command::new("prog") /// .arg(arg!(--flag "some flag")) /// .try_get_matches_from(vec!["prog", "--other"]); @@ -41,7 +41,7 @@ pub enum ErrorKind { /// #[cfg_attr(not(feature = "suggestions"), doc = " ```no_run")] #[cfg_attr(feature = "suggestions", doc = " ```")] - /// # use clap::{Command, Arg, ErrorKind, }; + /// # use clap::{Command, Arg, error::ErrorKind, }; /// let result = Command::new("prog") /// .subcommand(Command::new("config") /// .about("Used for configuration") @@ -60,7 +60,7 @@ pub enum ErrorKind { /// sign to provide values. /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let res = Command::new("prog") /// .arg(Arg::new("color") /// .action(ArgAction::Set) @@ -78,7 +78,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, value_parser}; + /// # use clap::{Command, Arg, error::ErrorKind, value_parser}; /// fn is_numeric(val: &str) -> Result<(), String> { /// match val.parse::() { /// Ok(..) => Ok(()), @@ -101,7 +101,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind}; + /// # use clap::{Command, Arg, error::ErrorKind}; /// let result = Command::new("prog") /// .arg(Arg::new("arg") /// .number_of_values(1..=2) @@ -120,7 +120,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind}; + /// # use clap::{Command, Arg, error::ErrorKind}; /// let result = Command::new("prog") /// .arg(Arg::new("some_opt") /// .long("opt") @@ -139,7 +139,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let result = Command::new("prog") /// .arg(Arg::new("some_opt") /// .long("opt") @@ -160,7 +160,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// let result = Command::new("prog") /// .arg(Arg::new("debug") /// .long("debug") @@ -180,7 +180,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind}; + /// # use clap::{Command, Arg, error::ErrorKind}; /// let result = Command::new("prog") /// .arg(Arg::new("debug") /// .required(true)) @@ -196,7 +196,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, ErrorKind}; + /// # use clap::{Command, error::ErrorKind}; /// let err = Command::new("prog") /// .subcommand_required(true) /// .subcommand(Command::new("test")) @@ -226,7 +226,7 @@ pub enum ErrorKind { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```")] - /// # use clap::{Command, Arg, ErrorKind, ArgAction}; + /// # use clap::{Command, Arg, error::ErrorKind, ArgAction}; /// # use std::os::unix::ffi::OsStringExt; /// # use std::ffi::OsString; /// let result = Command::new("prog") @@ -253,7 +253,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind}; + /// # use clap::{Command, Arg, error::ErrorKind}; /// let result = Command::new("prog") /// .try_get_matches_from(vec!["prog", "--help"]); /// assert!(result.is_err()); @@ -268,7 +268,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind, }; + /// # use clap::{Command, Arg, error::ErrorKind, }; /// let result = Command::new("prog") /// .arg_required_else_help(true) /// .subcommand(Command::new("config") @@ -290,7 +290,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ErrorKind}; + /// # use clap::{Command, Arg, error::ErrorKind}; /// let result = Command::new("prog") /// .version("3.0") /// .try_get_matches_from(vec!["prog", "--version"]); diff --git a/src/lib.rs b/src/lib.rs index e8ae2015..46dc8891 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -99,6 +99,7 @@ compile_error!("`std` feature is currently required to build `clap`"); pub use crate::builder::ArgAction; pub use crate::builder::Command; +pub use crate::builder::ValueHint; pub use crate::builder::{Arg, ArgGroup}; pub use crate::error::Error; pub use crate::parser::ArgMatches; @@ -110,12 +111,6 @@ pub(crate) use crate::util::color::ColorChoice; pub use crate::derive::{Args, CommandFactory, FromArgMatches, Parser, Subcommand, ValueEnum}; -#[allow(deprecated)] -pub use crate::builder::{PossibleValue, ValueHint}; -pub use crate::error::{ErrorKind, Result}; -#[allow(deprecated)] -pub use crate::parser::{Indices, ValueSource}; - #[cfg(feature = "derive")] #[doc(hidden)] pub use clap_derive::{self, *}; diff --git a/src/macros.rs b/src/macros.rs index cb3d6d2e..426189e6 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -562,7 +562,6 @@ macro_rules! impl_settings { #[allow(dead_code)] pub(crate) fn set(&mut self, s: $settings) { - #[allow(deprecated)] // some Settings might be deprecated match s { $( $(#[$inner $($args)*])* @@ -573,7 +572,6 @@ macro_rules! impl_settings { #[allow(dead_code)] pub(crate) fn unset(&mut self, s: $settings) { - #[allow(deprecated)] // some Settings might be deprecated match s { $( $(#[$inner $($args)*])* @@ -584,7 +582,6 @@ macro_rules! impl_settings { #[allow(dead_code)] pub(crate) fn is_set(&self, s: $settings) -> bool { - #[allow(deprecated)] // some Settings might be deprecated match s { $( $(#[$inner $($args)*])* diff --git a/src/output/help.rs b/src/output/help.rs index 09a3013c..394256b2 100644 --- a/src/output/help.rs +++ b/src/output/help.rs @@ -6,10 +6,10 @@ use std::io::{self, Write}; use std::usize; // Internal +use crate::builder::PossibleValue; use crate::builder::{render_arg_val, Arg, Command}; use crate::output::{fmt::Colorizer, Usage}; use crate::ArgAction; -use crate::PossibleValue; // Third party use indexmap::IndexSet; diff --git a/src/output/usage.rs b/src/output/usage.rs index 8dec6807..ae7c3b4b 100644 --- a/src/output/usage.rs +++ b/src/output/usage.rs @@ -128,7 +128,6 @@ impl<'help, 'cmd> Usage<'help, 'cmd> { || self.cmd.is_allow_external_subcommands_set() { let placeholder = self.cmd.get_subcommand_value_name().unwrap_or("SUBCOMMAND"); - #[allow(deprecated)] if self.cmd.is_subcommand_negates_reqs_set() || self.cmd.is_args_conflicts_with_subcommands_set() { diff --git a/src/parser/arg_matcher.rs b/src/parser/arg_matcher.rs index 5856d6e0..a2599ea2 100644 --- a/src/parser/arg_matcher.rs +++ b/src/parser/arg_matcher.rs @@ -159,8 +159,6 @@ impl ArgMatcher { let ma = self.entry(id).or_insert(MatchedArg::new_arg(arg)); debug_assert_eq!(ma.type_id(), Some(arg.get_value_parser().type_id())); ma.set_source(ValueSource::CommandLine); - #[allow(deprecated)] - ma.inc_occurrences(); ma.new_val_group(); } @@ -169,8 +167,6 @@ impl ArgMatcher { let ma = self.entry(id).or_insert(MatchedArg::new_group()); debug_assert_eq!(ma.type_id(), None); ma.set_source(ValueSource::CommandLine); - #[allow(deprecated)] - ma.inc_occurrences(); ma.new_val_group(); } @@ -187,8 +183,6 @@ impl ArgMatcher { ) ); ma.set_source(ValueSource::CommandLine); - #[allow(deprecated)] - ma.inc_occurrences(); ma.new_val_group(); } diff --git a/src/parser/matches/arg_matches.rs b/src/parser/matches/arg_matches.rs index 0c8dcb0d..c2b6f2e8 100644 --- a/src/parser/matches/arg_matches.rs +++ b/src/parser/matches/arg_matches.rs @@ -26,7 +26,8 @@ use crate::INTERNAL_ERROR_MSG; /// # Examples /// /// ```no_run -/// # use clap::{Command, Arg, ValueSource, ArgAction}; +/// # use clap::{Command, Arg, ArgAction}; +/// # use clap::parser::ValueSource; /// let matches = Command::new("MyApp") /// .arg(Arg::new("out") /// .long("output") @@ -381,25 +382,6 @@ impl ArgMatches { Some(v) } - /// Deprecated, replaced with [`ArgAction::SetTrue`][crate::ArgAction] or - /// [`ArgMatches::contains_id`]. - #[cfg_attr( - feature = "deprecated", - deprecated( - since = "3.2.0", - note = "Replaced with either `ArgAction::SetTrue` or `ArgMatches::contains_id(...)`" - ) - )] - #[cfg_attr(debug_assertions, track_caller)] - pub fn is_present(&self, id: T) -> bool { - let id = Id::from(id); - - #[cfg(debug_assertions)] - self.get_arg(&id); - - self.args.contains_key(&id) - } - /// Report where argument value came from /// /// # Panics @@ -409,7 +391,8 @@ impl ArgMatches { /// # Examples /// /// ```rust - /// # use clap::{Command, Arg, ValueSource, ArgAction}; + /// # use clap::{Command, Arg, ArgAction}; + /// # use clap::parser::ValueSource; /// let m = Command::new("myprog") /// .arg(Arg::new("debug") /// .short('d') @@ -431,22 +414,6 @@ impl ArgMatches { value.and_then(MatchedArg::source) } - /// Deprecated, replaced with [`ArgAction::Count`][crate::ArgAction], - /// [`ArgMatches::get_many`]`.len()`, or [`ArgMatches::value_source`]. - #[cfg_attr( - feature = "deprecated", - deprecated( - since = "3.2.0", - note = "Replaced with either `ArgAction::Count`, `ArgMatches::get_many(...).len()`, or `ArgMatches::value_source`" - ) - )] - #[cfg_attr(debug_assertions, track_caller)] - pub fn occurrences_of(&self, id: T) -> u64 { - #![allow(deprecated)] - self.get_arg(&Id::from(id)) - .map_or(0, |a| a.get_occurrences()) - } - /// The first index of that an argument showed up. /// /// Indices are similar to argv indices, but are not exactly 1:1. @@ -1344,7 +1311,6 @@ impl<'a> ExactSizeIterator for GroupedValues<'a> {} /// Creates an empty iterator. Used for `unwrap_or_default()`. impl<'a> Default for GroupedValues<'a> { fn default() -> Self { - #![allow(deprecated)] static EMPTY: [Vec; 0] = []; GroupedValues { iter: EMPTY[..].iter().map(|_| unreachable!()), diff --git a/src/parser/matches/matched_arg.rs b/src/parser/matches/matched_arg.rs index d031ebd7..c8fb80a5 100644 --- a/src/parser/matches/matched_arg.rs +++ b/src/parser/matches/matched_arg.rs @@ -14,7 +14,6 @@ use crate::INTERNAL_ERROR_MSG; #[derive(Debug, Clone)] pub(crate) struct MatchedArg { - occurs: u64, source: Option, indices: Vec, type_id: Option, @@ -27,7 +26,6 @@ impl MatchedArg { pub(crate) fn new_arg(arg: &crate::Arg) -> Self { let ignore_case = arg.is_ignore_case_set(); Self { - occurs: 0, source: None, indices: Vec::new(), type_id: Some(arg.get_value_parser().type_id()), @@ -40,7 +38,6 @@ impl MatchedArg { pub(crate) fn new_group() -> Self { let ignore_case = false; Self { - occurs: 0, source: None, indices: Vec::new(), type_id: None, @@ -53,7 +50,6 @@ impl MatchedArg { pub(crate) fn new_external(cmd: &crate::Command) -> Self { let ignore_case = false; Self { - occurs: 0, source: None, indices: Vec::new(), type_id: Some( @@ -67,16 +63,6 @@ impl MatchedArg { } } - #[cfg_attr(feature = "deprecated", deprecated(since = "3.2.0"))] - pub(crate) fn inc_occurrences(&mut self) { - self.occurs += 1; - } - - #[cfg_attr(feature = "deprecated", deprecated(since = "3.2.0"))] - pub(crate) fn get_occurrences(&self) -> u64 { - self.occurs - } - pub(crate) fn indices(&self) -> Cloned> { self.indices.iter().cloned() } @@ -190,7 +176,6 @@ impl MatchedArg { impl PartialEq for MatchedArg { fn eq(&self, other: &MatchedArg) -> bool { let MatchedArg { - occurs: self_occurs, source: self_source, indices: self_indices, type_id: self_type_id, @@ -199,7 +184,6 @@ impl PartialEq for MatchedArg { ignore_case: self_ignore_case, } = self; let MatchedArg { - occurs: other_occurs, source: other_source, indices: other_indices, type_id: other_type_id, @@ -207,8 +191,7 @@ impl PartialEq for MatchedArg { raw_vals: other_raw_vals, ignore_case: other_ignore_case, } = other; - self_occurs == other_occurs - && self_source == other_source + self_source == other_source && self_indices == other_indices && self_type_id == other_type_id && self_raw_vals == other_raw_vals diff --git a/tests/builder/action.rs b/tests/builder/action.rs index af41a25f..9e7326a6 100644 --- a/tests/builder/action.rs +++ b/tests/builder/action.rs @@ -11,10 +11,6 @@ fn set() { let matches = cmd.clone().try_get_matches_from(["test"]).unwrap(); assert_eq!(matches.get_one::("mammal"), None); assert_eq!(matches.contains_id("mammal"), false); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), None); let matches = cmd @@ -23,10 +19,6 @@ fn set() { .unwrap(); assert_eq!(matches.get_one::("mammal").unwrap(), "dog"); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(2)); let matches = cmd @@ -35,10 +27,6 @@ fn set() { .unwrap(); assert_eq!(matches.get_one::("mammal").unwrap(), "cat"); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(4)); } @@ -49,10 +37,6 @@ fn append() { let matches = cmd.clone().try_get_matches_from(["test"]).unwrap(); assert_eq!(matches.get_one::("mammal"), None); assert_eq!(matches.contains_id("mammal"), false); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), None); let matches = cmd @@ -61,10 +45,6 @@ fn append() { .unwrap(); assert_eq!(matches.get_one::("mammal").unwrap(), "dog"); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!( matches.indices_of("mammal").unwrap().collect::>(), vec![2] @@ -83,10 +63,6 @@ fn append() { vec!["dog", "cat"] ); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!( matches.indices_of("mammal").unwrap().collect::>(), vec![2, 4] @@ -101,10 +77,6 @@ fn set_true() { let matches = cmd.clone().try_get_matches_from(["test"]).unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), false); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); let matches = cmd @@ -113,10 +85,6 @@ fn set_true() { .unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), true); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); let matches = cmd @@ -125,10 +93,6 @@ fn set_true() { .unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), true); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(2)); } @@ -147,19 +111,11 @@ fn set_true_with_explicit_default_value() { .unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), true); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); let matches = cmd.clone().try_get_matches_from(["test"]).unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), false); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); } @@ -258,10 +214,6 @@ fn set_false() { let matches = cmd.clone().try_get_matches_from(["test"]).unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), true); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); let matches = cmd @@ -270,10 +222,6 @@ fn set_false() { .unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), false); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); let matches = cmd @@ -282,10 +230,6 @@ fn set_false() { .unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), false); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(2)); } @@ -304,19 +248,11 @@ fn set_false_with_explicit_default_value() { .unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), false); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); let matches = cmd.clone().try_get_matches_from(["test"]).unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), true); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); } @@ -381,10 +317,6 @@ fn count() { let matches = cmd.clone().try_get_matches_from(["test"]).unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), 0); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); let matches = cmd @@ -393,10 +325,6 @@ fn count() { .unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), 1); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); let matches = cmd @@ -405,10 +333,6 @@ fn count() { .unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), 2); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(2)); } @@ -427,19 +351,11 @@ fn count_with_explicit_default_value() { .unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), 1); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); let matches = cmd.clone().try_get_matches_from(["test"]).unwrap(); assert_eq!(*matches.get_one::("mammal").unwrap(), 10); assert_eq!(matches.contains_id("mammal"), true); - #[allow(deprecated)] - { - assert_eq!(matches.occurrences_of("mammal"), 0); - } assert_eq!(matches.index_of("mammal"), Some(1)); } diff --git a/tests/builder/app_settings.rs b/tests/builder/app_settings.rs index a415f8c6..23bf93eb 100644 --- a/tests/builder/app_settings.rs +++ b/tests/builder/app_settings.rs @@ -1218,7 +1218,6 @@ fn aaos_pos_mult() { #[test] fn aaos_option_use_delim_false() { - #![allow(deprecated)] let m = Command::new("posix") .arg( arg!(--opt "some option") diff --git a/tests/builder/default_missing_vals.rs b/tests/builder/default_missing_vals.rs index f00fb007..6c441c5b 100644 --- a/tests/builder/default_missing_vals.rs +++ b/tests/builder/default_missing_vals.rs @@ -21,7 +21,7 @@ fn opt_missing() { ); assert_eq!( m.value_source("color").unwrap(), - clap::ValueSource::DefaultValue + clap::parser::ValueSource::DefaultValue ); assert_eq!(m.index_of("color"), Some(1)); } @@ -47,7 +47,7 @@ fn opt_present_with_missing_value() { ); assert_eq!( m.value_source("color").unwrap(), - clap::ValueSource::CommandLine + clap::parser::ValueSource::CommandLine ); assert_eq!(m.index_of("color"), Some(2)); } @@ -73,7 +73,7 @@ fn opt_present_with_value() { ); assert_eq!( m.value_source("color").unwrap(), - clap::ValueSource::CommandLine + clap::parser::ValueSource::CommandLine ); assert_eq!(m.index_of("color"), Some(2)); } @@ -98,7 +98,7 @@ fn opt_present_with_empty_value() { ); assert_eq!( m.value_source("color").unwrap(), - clap::ValueSource::CommandLine + clap::parser::ValueSource::CommandLine ); assert_eq!(m.index_of("color"), Some(2)); } @@ -183,7 +183,7 @@ fn default_missing_value_flag_value() { ); assert_eq!( m.value_source("flag").unwrap(), - clap::ValueSource::DefaultValue + clap::parser::ValueSource::DefaultValue ); let m = cmd @@ -197,7 +197,7 @@ fn default_missing_value_flag_value() { ); assert_eq!( m.value_source("flag").unwrap(), - clap::ValueSource::CommandLine + clap::parser::ValueSource::CommandLine ); let m = cmd @@ -211,7 +211,7 @@ fn default_missing_value_flag_value() { ); assert_eq!( m.value_source("flag").unwrap(), - clap::ValueSource::CommandLine + clap::parser::ValueSource::CommandLine ); let m = cmd.try_get_matches_from(&["test", "--flag=false"]).unwrap(); @@ -222,7 +222,7 @@ fn default_missing_value_flag_value() { ); assert_eq!( m.value_source("flag").unwrap(), - clap::ValueSource::CommandLine + clap::parser::ValueSource::CommandLine ); } @@ -308,7 +308,7 @@ fn valid_index() { ); assert_eq!( m.value_source("color").unwrap(), - clap::ValueSource::CommandLine + clap::parser::ValueSource::CommandLine ); // Make sure the index reflects `--color`s position and not something else diff --git a/tests/builder/help.rs b/tests/builder/help.rs index c6e3a452..45d5f158 100644 --- a/tests/builder/help.rs +++ b/tests/builder/help.rs @@ -1,6 +1,6 @@ use super::utils; -use clap::{arg, error::ErrorKind, Arg, ArgAction, ArgGroup, Command, PossibleValue}; +use clap::{arg, builder::PossibleValue, error::ErrorKind, Arg, ArgAction, ArgGroup, Command}; fn setup() -> Command<'static> { Command::new("test") diff --git a/tests/builder/possible_values.rs b/tests/builder/possible_values.rs index f6021964..a65f75a1 100644 --- a/tests/builder/possible_values.rs +++ b/tests/builder/possible_values.rs @@ -1,6 +1,6 @@ use super::utils; -use clap::{error::ErrorKind, Arg, ArgAction, Command, PossibleValue}; +use clap::{builder::PossibleValue, error::ErrorKind, Arg, ArgAction, Command}; #[cfg(feature = "suggestions")] static PV_ERROR: &str = "error: \"slo\" isn't a valid value for '-O