clap/src/lib.rs

105 lines
3.2 KiB
Rust
Raw Normal View History

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).
// 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.
#![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")]
#![cfg_attr(feature = "derive", doc = include_str!("../README.md"))]
2021-07-03 21:59:46 +00:00
//! <https://github.com/clap-rs/clap>
#![warn(
2019-04-05 19:51:22 +00:00
missing_docs,
missing_debug_implementations,
missing_copy_implementations,
trivial_casts,
unused_allocation,
trivial_numeric_casts
)]
2020-08-20 22:38:40 +00:00
#![forbid(unsafe_code)]
// HACK https://github.com/rust-lang/rust-clippy/issues/7290
2021-06-17 18:19:56 +00:00
#![allow(clippy::single_component_path_imports)]
#![allow(clippy::branches_sharing_code)]
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
#[cfg(feature = "color")]
pub use crate::util::color::ColorChoice;
2020-04-27 18:47:08 +00:00
pub use crate::{
2021-09-23 09:27:10 +00:00
build::{
App, AppFlags, AppSettings, Arg, ArgFlags, ArgGroup, ArgSettings, PossibleValue, ValueHint,
2021-09-23 09:27:10 +00:00
},
2020-04-27 18:47:08 +00:00
parse::errors::{Error, ErrorKind, Result},
2020-06-08 13:31:51 +00:00
parse::{ArgMatches, Indices, OsValues, Values},
2020-04-27 18:47:08 +00:00
};
2020-02-14 16:22:01 +00:00
pub use crate::derive::{ArgEnum, Args, FromArgMatches, IntoApp, Parser, Subcommand};
#[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",
note = "Deprecated in Issue #3087, maybe clap::Parser would fit your use case?"
2021-11-23 16:11:02 +00:00
)]
pub use yaml_rust::YamlLoader;
2015-02-25 13:37:25 +00:00
#[cfg(feature = "derive")]
2020-09-24 11:41:37 +00:00
#[doc(hidden)]
pub use clap_derive::{self, *};
/// Deprecated, replaced with [`Parser`]
#[deprecated(since = "3.0.0", note = "Replaced with `Parser`")]
pub use Parser as StructOpt;
#[cfg(any(feature = "derive", feature = "cargo"))]
#[doc(hidden)]
pub use lazy_static;
#[macro_use]
2020-01-01 17:57:44 +00:00
#[allow(missing_docs)]
mod macros;
2018-07-26 15:15:47 +00:00
mod derive;
#[cfg(feature = "regex")]
pub use crate::build::arg::RegexRef;
mod build;
2018-07-19 12:50:47 +00:00
mod mkeymap;
mod output;
mod parse;
mod util;
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";
/// Deprecated, replaced with [`App::new`], unless you were looking for [Subcommand]
#[deprecated(
since = "3.0.0",
note = "Replaced with `App::new` unless you intended the `Subcommand` trait"
)]
#[derive(Debug, Copy, Clone)]
pub struct SubCommand {}
2021-11-23 16:11:02 +00:00
#[allow(deprecated)]
impl SubCommand {
/// Deprecated, replaced with [`App::new`].
/// Did you mean Subcommand (lower-case c)?
2021-11-23 16:11:02 +00:00
#[deprecated(since = "3.0.0", note = "Replaced with `App::new`")]
pub fn with_name<'help>(name: &str) -> App<'help> {
App::new(name)
}
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?
#[cfg(feature = "yaml")]
2021-11-18 20:27:21 +00:00
#[deprecated(
since = "3.0.0",
note = "Deprecated in Issue #3087, maybe clap::Parser would fit your use case?"
2021-11-18 20:27:21 +00:00
)]
pub fn from_yaml(yaml: &yaml_rust::Yaml) -> App {
2021-11-18 20:27:21 +00:00
#![allow(deprecated)]
App::from_yaml(yaml)
}
}