2020-03-02 08:52:15 +00:00
|
|
|
// Copyright ⓒ 2015-2016 Kevin B. Knapp and [`clap-rs` contributors](https://github.com/clap-rs/clap/graphs/contributors).
|
2016-01-31 13:03:09 +00:00
|
|
|
// Licensed under the MIT license
|
|
|
|
// (see LICENSE or <http://opensource.org/licenses/MIT>) All files in the project carrying such
|
|
|
|
// notice may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2021-12-16 16:36:41 +00:00
|
|
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
2021-12-07 22:22:14 +00:00
|
|
|
#![doc(html_logo_url = "https://raw.githubusercontent.com/clap-rs/clap/master/assets/clap.png")]
|
2021-12-09 02:03:19 +00:00
|
|
|
#![cfg_attr(feature = "derive", doc = include_str!("../README.md"))]
|
2021-07-03 21:59:46 +00:00
|
|
|
//! <https://github.com/clap-rs/clap>
|
2021-12-06 17:03:12 +00:00
|
|
|
#![warn(
|
2019-04-05 19:51:22 +00:00
|
|
|
missing_docs,
|
|
|
|
missing_debug_implementations,
|
|
|
|
missing_copy_implementations,
|
|
|
|
trivial_casts,
|
|
|
|
unused_allocation,
|
2022-01-04 07:20:03 +00:00
|
|
|
trivial_numeric_casts,
|
|
|
|
clippy::single_char_pattern
|
2019-04-05 19:51:22 +00:00
|
|
|
)]
|
2020-08-20 22:38:40 +00:00
|
|
|
#![forbid(unsafe_code)]
|
2021-12-22 15:52:02 +00:00
|
|
|
// HACK https://github.com/rust-lang/rust-clippy/issues/7290
|
2021-06-17 18:19:56 +00:00
|
|
|
#![allow(clippy::single_component_path_imports)]
|
2021-10-23 15:06:19 +00:00
|
|
|
#![allow(clippy::branches_sharing_code)]
|
2022-01-04 15:00:13 +00:00
|
|
|
// Doesn't allow for debug statements, etc to be unique
|
|
|
|
#![allow(clippy::if_same_then_else)]
|
2015-08-20 01:44:25 +00:00
|
|
|
|
2020-02-02 01:02:10 +00:00
|
|
|
#[cfg(not(feature = "std"))]
|
2020-03-19 07:17:52 +00:00
|
|
|
compile_error!("`std` feature is currently required to build `clap`");
|
2020-02-02 01:02:10 +00:00
|
|
|
|
2022-05-12 10:03:26 +00:00
|
|
|
pub use crate::builder::Command;
|
2022-05-12 10:07:54 +00:00
|
|
|
pub use crate::builder::{Arg, ArgGroup};
|
2022-02-02 22:06:23 +00:00
|
|
|
pub use crate::error::Error;
|
2022-05-12 10:07:54 +00:00
|
|
|
pub use crate::parser::ArgMatches;
|
2021-10-27 21:01:04 +00:00
|
|
|
#[cfg(feature = "color")]
|
|
|
|
pub use crate::util::color::ColorChoice;
|
2022-04-22 17:19:43 +00:00
|
|
|
#[cfg(not(feature = "color"))]
|
|
|
|
#[allow(unused_imports)]
|
|
|
|
pub(crate) use crate::util::color::ColorChoice;
|
2020-02-14 16:22:01 +00:00
|
|
|
|
2022-02-14 22:09:38 +00:00
|
|
|
pub use crate::derive::{ArgEnum, Args, CommandFactory, FromArgMatches, Parser, Subcommand};
|
2020-08-11 14:30:02 +00:00
|
|
|
|
2022-02-12 03:48:29 +00:00
|
|
|
#[allow(deprecated)]
|
2022-05-12 10:03:26 +00:00
|
|
|
pub use crate::builder::App;
|
2022-05-12 10:07:54 +00:00
|
|
|
pub use crate::builder::{AppFlags, AppSettings, ArgFlags, ArgSettings, PossibleValue, ValueHint};
|
|
|
|
pub use crate::error::{ErrorKind, Result};
|
|
|
|
pub use crate::parser::{Indices, OsValues, ValueSource, Values};
|
2022-02-12 03:48:29 +00:00
|
|
|
|
2018-07-23 19:09:42 +00:00
|
|
|
#[cfg(feature = "yaml")]
|
2020-09-24 11:41:37 +00:00
|
|
|
#[doc(hidden)]
|
2021-11-23 16:11:02 +00:00
|
|
|
#[deprecated(
|
|
|
|
since = "3.0.0",
|
2021-12-09 12:47:33 +00:00
|
|
|
note = "Deprecated in Issue #3087, maybe clap::Parser would fit your use case?"
|
2021-11-23 16:11:02 +00:00
|
|
|
)]
|
2022-02-12 00:42:26 +00:00
|
|
|
#[doc(hidden)]
|
2018-07-23 19:09:42 +00:00
|
|
|
pub use yaml_rust::YamlLoader;
|
2015-02-25 13:37:25 +00:00
|
|
|
|
2018-07-13 15:36:53 +00:00
|
|
|
#[cfg(feature = "derive")]
|
2020-09-24 11:41:37 +00:00
|
|
|
#[doc(hidden)]
|
2019-12-29 15:53:12 +00:00
|
|
|
pub use clap_derive::{self, *};
|
|
|
|
|
2022-02-14 22:09:38 +00:00
|
|
|
/// Deprecated, replaced with [`CommandFactory`]
|
|
|
|
#[deprecated(since = "3.0.0", note = "Replaced with `CommandFactory`")]
|
|
|
|
pub use CommandFactory as IntoApp;
|
2021-12-03 02:18:33 +00:00
|
|
|
/// Deprecated, replaced with [`Parser`]
|
|
|
|
#[deprecated(since = "3.0.0", note = "Replaced with `Parser`")]
|
2022-02-12 00:42:26 +00:00
|
|
|
#[doc(hidden)]
|
2021-12-03 02:18:33 +00:00
|
|
|
pub use Parser as StructOpt;
|
|
|
|
|
2020-08-21 05:21:21 +00:00
|
|
|
#[cfg(any(feature = "derive", feature = "cargo"))]
|
|
|
|
#[doc(hidden)]
|
2019-12-29 15:53:12 +00:00
|
|
|
pub use lazy_static;
|
2018-07-13 15:36:53 +00:00
|
|
|
|
2015-04-10 15:40:08 +00:00
|
|
|
#[macro_use]
|
2020-01-01 17:57:44 +00:00
|
|
|
#[allow(missing_docs)]
|
2020-05-15 07:51:36 +00:00
|
|
|
mod macros;
|
2018-07-26 15:15:47 +00:00
|
|
|
|
2020-05-15 07:51:36 +00:00
|
|
|
mod derive;
|
2020-02-08 19:36:00 +00:00
|
|
|
|
2020-08-26 15:49:54 +00:00
|
|
|
#[cfg(feature = "regex")]
|
2022-05-12 10:03:26 +00:00
|
|
|
pub use crate::builder::RegexRef;
|
2020-08-26 15:49:54 +00:00
|
|
|
|
2022-05-12 10:03:26 +00:00
|
|
|
pub mod builder;
|
2022-02-02 22:06:23 +00:00
|
|
|
pub mod error;
|
2022-05-12 10:03:26 +00:00
|
|
|
pub mod parser;
|
2022-02-02 22:06:23 +00:00
|
|
|
|
2018-07-19 12:50:47 +00:00
|
|
|
mod mkeymap;
|
2018-07-23 19:09:42 +00:00
|
|
|
mod output;
|
2018-06-12 15:42:03 +00:00
|
|
|
mod util;
|
2016-01-11 08:59:56 +00:00
|
|
|
|
2018-11-14 17:12:34 +00:00
|
|
|
const INTERNAL_ERROR_MSG: &str = "Fatal internal error. Please consider filing a bug \
|
2020-02-05 10:04:59 +00:00
|
|
|
report at https://github.com/clap-rs/clap/issues";
|
2018-11-14 17:12:34 +00:00
|
|
|
const INVALID_UTF8: &str = "unexpected invalid UTF-8 code point";
|
2021-08-18 15:53:05 +00:00
|
|
|
|
2022-02-12 03:48:29 +00:00
|
|
|
/// Deprecated, replaced with [`Command::new`], unless you were looking for [Subcommand]
|
2021-12-11 22:47:08 +00:00
|
|
|
#[deprecated(
|
|
|
|
since = "3.0.0",
|
2022-02-12 03:48:29 +00:00
|
|
|
note = "Replaced with `Command::new` unless you intended the `Subcommand` trait"
|
2021-12-11 22:47:08 +00:00
|
|
|
)]
|
2022-02-12 00:42:26 +00:00
|
|
|
#[doc(hidden)]
|
2021-08-18 15:53:05 +00:00
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
pub struct SubCommand {}
|
|
|
|
|
2021-11-23 16:11:02 +00:00
|
|
|
#[allow(deprecated)]
|
2021-08-18 15:53:05 +00:00
|
|
|
impl SubCommand {
|
2022-02-12 03:48:29 +00:00
|
|
|
/// Deprecated, replaced with [`Command::new`].
|
2021-12-11 22:47:08 +00:00
|
|
|
/// Did you mean Subcommand (lower-case c)?
|
2022-02-12 03:48:29 +00:00
|
|
|
#[deprecated(since = "3.0.0", note = "Replaced with `Command::new`")]
|
2022-02-12 00:42:26 +00:00
|
|
|
#[doc(hidden)]
|
2021-08-18 15:53:05 +00:00
|
|
|
pub fn with_name<'help>(name: &str) -> App<'help> {
|
2022-02-12 03:48:29 +00:00
|
|
|
Command::new(name)
|
2021-08-18 15:53:05 +00:00
|
|
|
}
|
|
|
|
|
2021-12-08 17:11:26 +00:00
|
|
|
/// Deprecated in [Issue #3087](https://github.com/clap-rs/clap/issues/3087), maybe [`clap::Parser`][crate::Parser] would fit your use case?
|
2021-08-18 15:53:05 +00:00
|
|
|
#[cfg(feature = "yaml")]
|
2021-11-18 20:27:21 +00:00
|
|
|
#[deprecated(
|
|
|
|
since = "3.0.0",
|
2021-12-09 12:47:33 +00:00
|
|
|
note = "Deprecated in Issue #3087, maybe clap::Parser would fit your use case?"
|
2021-11-18 20:27:21 +00:00
|
|
|
)]
|
2022-02-12 00:42:26 +00:00
|
|
|
#[doc(hidden)]
|
2021-08-18 15:53:05 +00:00
|
|
|
pub fn from_yaml(yaml: &yaml_rust::Yaml) -> App {
|
2021-11-18 20:27:21 +00:00
|
|
|
#![allow(deprecated)]
|
2022-02-12 03:48:29 +00:00
|
|
|
Command::from_yaml(yaml)
|
2021-08-18 15:53:05 +00:00
|
|
|
}
|
|
|
|
}
|