mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 23:02:31 +00:00
fix a bunch of intra-doc links
This commit is contained in:
parent
89d1519f69
commit
f5758034f0
6 changed files with 43 additions and 31 deletions
|
@ -167,6 +167,7 @@ impl_settings! { AppSettings, AppFlags,
|
|||
/// **NOTE:** When these settings are used, they apply only to current command, and are *not*
|
||||
/// propagated down or up through child or parent subcommands
|
||||
///
|
||||
/// [`App`]: crate::App
|
||||
#[derive(Debug, PartialEq, Copy, Clone)]
|
||||
pub enum AppSettings {
|
||||
/// Specifies that any invalid UTF-8 code points should *not* be treated as an error.
|
||||
|
|
|
@ -72,9 +72,9 @@ use yaml_rust::Yaml;
|
|||
/// ```
|
||||
/// [`ArgGroup::multiple(true)`]: ArgGroup::multiple()
|
||||
/// [`ArgGroup::multiple(false)`]: ArgGroup::multiple()
|
||||
/// [arguments]: Arg
|
||||
/// [conflict]: Arg::conflicts_with()
|
||||
/// [requirement]: Arg::requires()
|
||||
/// [arguments]: crate::Arg
|
||||
/// [conflict]: crate::Arg::conflicts_with()
|
||||
/// [requirement]: crate::Arg::requires()
|
||||
#[derive(Default, Debug, PartialEq, Eq)]
|
||||
pub struct ArgGroup<'help> {
|
||||
pub(crate) id: Id,
|
||||
|
@ -133,7 +133,7 @@ impl<'help> ArgGroup<'help> {
|
|||
/// // but we can also check individually if needed
|
||||
/// assert!(m.is_present("flag"));
|
||||
/// ```
|
||||
/// [argument]: Arg
|
||||
/// [argument]: crate::Arg
|
||||
pub fn arg<T: Key>(mut self, arg_id: T) -> Self {
|
||||
self.args.push(arg_id.into());
|
||||
self
|
||||
|
@ -158,7 +158,7 @@ impl<'help> ArgGroup<'help> {
|
|||
/// // but we can also check individually if needed
|
||||
/// assert!(m.is_present("flag"));
|
||||
/// ```
|
||||
/// [arguments]: Arg
|
||||
/// [arguments]: crate::Arg
|
||||
pub fn args<T: Key>(mut self, ns: &[T]) -> Self {
|
||||
for n in ns {
|
||||
self = self.arg(n);
|
||||
|
@ -205,6 +205,8 @@ impl<'help> ArgGroup<'help> {
|
|||
/// let err = result.unwrap_err();
|
||||
/// assert_eq!(err.kind, ErrorKind::ArgumentConflict);
|
||||
/// ```
|
||||
///
|
||||
/// [`Arg`]: crate::Arg
|
||||
#[inline]
|
||||
pub fn multiple(mut self, m: bool) -> Self {
|
||||
self.multiple = m;
|
||||
|
@ -245,6 +247,7 @@ impl<'help> ArgGroup<'help> {
|
|||
///
|
||||
/// [`Subcommand`]: crate::Subcommand
|
||||
/// [`ArgGroup::multiple`]: ArgGroup::multiple()
|
||||
/// [`App`]: crate::App
|
||||
#[inline]
|
||||
pub fn required(mut self, r: bool) -> Self {
|
||||
self.required = r;
|
||||
|
@ -280,7 +283,7 @@ impl<'help> ArgGroup<'help> {
|
|||
/// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
|
||||
/// ```
|
||||
/// [required group]: ArgGroup::required()
|
||||
/// [argument requirement rules]: Arg::requires()
|
||||
/// [argument requirement rules]: crate::Arg::requires()
|
||||
pub fn requires<T: Key>(mut self, id: T) -> Self {
|
||||
self.requires.push(id.into());
|
||||
self
|
||||
|
@ -317,7 +320,7 @@ impl<'help> ArgGroup<'help> {
|
|||
/// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
|
||||
/// ```
|
||||
/// [required group]: ArgGroup::required()
|
||||
/// [argument requirement rules]: Arg::requires_all()
|
||||
/// [argument requirement rules]: crate::Arg::requires_all()
|
||||
pub fn requires_all(mut self, ns: &[&'help str]) -> Self {
|
||||
for n in ns {
|
||||
self = self.requires(n);
|
||||
|
@ -351,7 +354,7 @@ impl<'help> ArgGroup<'help> {
|
|||
/// let err = result.unwrap_err();
|
||||
/// assert_eq!(err.kind, ErrorKind::ArgumentConflict);
|
||||
/// ```
|
||||
/// [argument exclusion rules]: Arg::conflicts_with()
|
||||
/// [argument exclusion rules]: crate::Arg::conflicts_with()
|
||||
pub fn conflicts_with<T: Key>(mut self, id: T) -> Self {
|
||||
self.conflicts.push(id.into());
|
||||
self
|
||||
|
@ -386,7 +389,8 @@ impl<'help> ArgGroup<'help> {
|
|||
/// let err = result.unwrap_err();
|
||||
/// assert_eq!(err.kind, ErrorKind::ArgumentConflict);
|
||||
/// ```
|
||||
/// [argument exclusion rules]: Arg::conflicts_with_all()
|
||||
///
|
||||
/// [argument exclusion rules]: crate::Arg::conflicts_with_all()
|
||||
pub fn conflicts_with_all(mut self, ns: &[&'help str]) -> Self {
|
||||
for n in ns {
|
||||
self = self.conflicts_with(n);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#![doc(html_logo_url = "https://clap.rs/images/media/clap.png")]
|
||||
#![doc(html_root_url = "https://docs.rs/clap/3.0.0-beta.2")]
|
||||
#![cfg_attr(feature = "doc", doc(include = "../README.md"))]
|
||||
//! https://github.com/clap-rs/clap
|
||||
//! <https://github.com/clap-rs/clap>
|
||||
#![crate_type = "lib"]
|
||||
#![deny(
|
||||
missing_docs,
|
||||
|
|
|
@ -286,15 +286,15 @@ macro_rules! app_from_crate {
|
|||
/// * `(@arg "something-else": --"something-else")`
|
||||
/// * `(@subcommand "something-else" => ...)`
|
||||
///
|
||||
/// [`Arg::short`]: Arg::short()
|
||||
/// [`Arg::long`]: Arg::long()
|
||||
/// [`Arg::multiple_values(true)`]: Arg::multiple_values()
|
||||
/// [`Arg::multiple_occurrences(true)`]: Arg::multiple_occurrences()
|
||||
/// [`Arg::value_name`]: Arg::value_name()
|
||||
/// [`Arg::min_values(min)`]: Arg::min_values()
|
||||
/// [`Arg::max_values(max)`]: Arg::max_values()
|
||||
/// [`Arg::validator`]: Arg::validator()
|
||||
/// [`Arg::conflicts_with`]: Arg::conflicts_with()
|
||||
/// [`Arg::short`]: crate::Arg::short()
|
||||
/// [`Arg::long`]: crate::Arg::long()
|
||||
/// [`Arg::multiple_values(true)`]: crate::Arg::multiple_values()
|
||||
/// [`Arg::multiple_occurrences(true)`]: crate::Arg::multiple_occurrences()
|
||||
/// [`Arg::value_name`]: crate::Arg::value_name()
|
||||
/// [`Arg::min_values(min)`]: crate::Arg::min_values()
|
||||
/// [`Arg::max_values(max)`]: crate::Arg::max_values()
|
||||
/// [`Arg::validator`]: crate::Arg::validator()
|
||||
/// [`Arg::conflicts_with`]: crate::Arg::conflicts_with()
|
||||
#[macro_export]
|
||||
macro_rules! clap_app {
|
||||
(@app ($builder:expr)) => { $builder };
|
||||
|
|
|
@ -290,6 +290,8 @@ pub enum ErrorKind {
|
|||
/// assert_eq!(err.unwrap_err().kind, ErrorKind::MissingSubcommand);
|
||||
/// # ;
|
||||
/// ```
|
||||
///
|
||||
/// [`AppSettings::SubcommandRequired`]: crate::AppSettings::SubcommandRequired
|
||||
MissingSubcommand,
|
||||
|
||||
/// Occurs when the user provides multiple values to an argument which doesn't allow that.
|
||||
|
@ -333,6 +335,8 @@ pub enum ErrorKind {
|
|||
/// assert!(result.is_err());
|
||||
/// assert_eq!(result.unwrap_err().kind, ErrorKind::InvalidUtf8);
|
||||
/// ```
|
||||
///
|
||||
/// [`AppSettings::StrictUtf8`]: crate::AppSettings::StrictUtf8
|
||||
InvalidUtf8,
|
||||
|
||||
/// Not a true "error" as it means `--help` or similar was used.
|
||||
|
@ -373,6 +377,8 @@ pub enum ErrorKind {
|
|||
/// ```
|
||||
///
|
||||
/// [`Subcommand`]: crate::Subcommand
|
||||
/// [`AppSettings::ArgRequiredElseHelp`]: crate::AppSettings::ArgRequiredElseHelp
|
||||
/// [`AppSettings::SubcommandRequiredElseHelp`]: crate::AppSettings::SubcommandRequiredElseHelp
|
||||
DisplayHelpOnMissingArgumentOrSubcommand,
|
||||
|
||||
/// Not a true "error" as it means `--version` or similar was used.
|
||||
|
@ -393,7 +399,7 @@ pub enum ErrorKind {
|
|||
/// into type `T`, but the argument you requested wasn't used. I.e. you asked for an argument
|
||||
/// with name `config` to be converted, but `config` wasn't used by the user.
|
||||
///
|
||||
/// [`ArgMatches::value_of_t`]: ArgMatches::value_of_t()
|
||||
/// [`ArgMatches::value_of_t`]: crate::ArgMatches::value_of_t()
|
||||
ArgumentNotFound,
|
||||
|
||||
/// Represents an [I/O error].
|
||||
|
|
|
@ -71,7 +71,7 @@ pub(crate) struct SubCommand {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
/// [`App::get_matches`]: App::get_matches()
|
||||
/// [`App::get_matches`]: crate::App::get_matches()
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ArgMatches {
|
||||
pub(crate) args: IndexMap<Id, MatchedArg>,
|
||||
|
@ -114,12 +114,11 @@ impl ArgMatches {
|
|||
///
|
||||
/// assert_eq!(m.value_of("output"), Some("something"));
|
||||
/// ```
|
||||
/// [option]: Arg::takes_value()
|
||||
/// [positional]: Arg::index()
|
||||
/// [option]: crate::Arg::takes_value()
|
||||
/// [positional]: crate::Arg::index()
|
||||
/// [`ArgMatches::values_of`]: ArgMatches::values_of()
|
||||
/// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html
|
||||
/// [`default_value`]: Arg::default_value()
|
||||
/// [`occurrences_of`]: ArgMatches::occurrences_of()
|
||||
/// [`default_value`]: crate::Arg::default_value()
|
||||
/// [`occurrences_of`]: crate::ArgMatches::occurrences_of()
|
||||
pub fn value_of<T: Key>(&self, id: T) -> Option<&str> {
|
||||
if let Some(arg) = self.args.get(&Id::from(id)) {
|
||||
if let Some(v) = arg.get_val(0) {
|
||||
|
@ -154,7 +153,7 @@ impl ArgMatches {
|
|||
/// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]);
|
||||
/// assert_eq!(&*m.value_of_lossy("arg").unwrap(), "Hi \u{FFFD}!");
|
||||
/// ```
|
||||
/// [`default_value`]: Arg::default_value()
|
||||
/// [`default_value`]: crate::Arg::default_value()
|
||||
/// [`occurrences_of`]: ArgMatches::occurrences_of()
|
||||
/// [`Arg::values_of_lossy`]: ArgMatches::values_of_lossy()
|
||||
pub fn value_of_lossy<T: Key>(&self, id: T) -> Option<Cow<'_, str>> {
|
||||
|
@ -194,9 +193,8 @@ impl ArgMatches {
|
|||
/// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]);
|
||||
/// assert_eq!(&*m.value_of_os("arg").unwrap().as_bytes(), [b'H', b'i', b' ', 0xe9, b'!']);
|
||||
/// ```
|
||||
/// [`default_value`]: Arg::default_value()
|
||||
/// [`default_value`]: crate::Arg::default_value()
|
||||
/// [`occurrences_of`]: ArgMatches::occurrences_of()
|
||||
/// [`String`]: std::string::String
|
||||
/// [`ArgMatches::values_of_os`]: ArgMatches::values_of_os()
|
||||
pub fn value_of_os<T: Key>(&self, id: T) -> Option<&OsStr> {
|
||||
self.args
|
||||
|
@ -365,6 +363,7 @@ impl ArgMatches {
|
|||
///
|
||||
/// [`ArgMatches::values_of_t`]: ArgMatches::values_of_t()
|
||||
/// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html
|
||||
/// [`ErrorKind`]: crate::ErrorKind
|
||||
pub fn value_of_t<R>(&self, name: &str) -> Result<R, Error>
|
||||
where
|
||||
R: FromStr,
|
||||
|
@ -535,7 +534,7 @@ impl ArgMatches {
|
|||
/// assert!(m.is_present("debug"));
|
||||
/// ```
|
||||
///
|
||||
/// [`default_value`]: Arg::default_value()
|
||||
/// [`default_value`]: crate::Arg::default_value()
|
||||
/// [`occurrences_of`]: ArgMatches::occurrences_of()
|
||||
pub fn is_present<T: Key>(&self, id: T) -> bool {
|
||||
let id = Id::from(id);
|
||||
|
@ -713,7 +712,7 @@ impl ArgMatches {
|
|||
/// assert_eq!(m.index_of("option"), Some(2));
|
||||
/// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 3, 4]);
|
||||
/// ```
|
||||
/// [delimiter]: Arg::value_delimiter()
|
||||
/// [delimiter]: crate::Arg::value_delimiter()
|
||||
pub fn index_of<T: Key>(&self, name: T) -> Option<usize> {
|
||||
if let Some(arg) = self.args.get(&Id::from(name)) {
|
||||
if let Some(i) = arg.get_index(0) {
|
||||
|
@ -830,6 +829,7 @@ impl ArgMatches {
|
|||
/// ```
|
||||
///
|
||||
/// [`Subcommand`]: crate::Subcommand
|
||||
/// [`App`]: crate::App
|
||||
pub fn subcommand_matches<T: Key>(&self, id: T) -> Option<&ArgMatches> {
|
||||
if let Some(ref s) = self.subcommand {
|
||||
if s.id == id.into() {
|
||||
|
@ -895,6 +895,7 @@ impl ArgMatches {
|
|||
/// }
|
||||
/// ```
|
||||
/// [`Subcommand`]: crate::Subcommand
|
||||
/// [`App`]: crate::App
|
||||
#[inline]
|
||||
pub fn subcommand_name(&self) -> Option<&str> {
|
||||
self.subcommand.as_ref().map(|sc| &*sc.name)
|
||||
|
|
Loading…
Reference in a new issue