Added macros
features
This commit is contained in:
parent
a2abf6b335
commit
417f0b723d
8
.github/workflows/crossterm.yml
vendored
8
.github/workflows/crossterm.yml
vendored
|
@ -65,14 +65,14 @@ jobs:
|
|||
|
||||
# build / doc / test
|
||||
- name: build_all
|
||||
run: cargo build --verbose --workspace --no-default-features --features=crossterm
|
||||
run: cargo build --verbose --workspace --no-default-features --features=crossterm,macros
|
||||
|
||||
# doesn't use --include-ignored as it was unstable in 1.47
|
||||
- name: test_regular
|
||||
run: cargo test --workspace --verbose --no-default-features --features=crossterm
|
||||
run: cargo test --workspace --verbose --no-default-features --features=crossterm,macros
|
||||
|
||||
- name: test_ignored
|
||||
run: cargo test --workspace --verbose --no-default-features --features=crossterm -- --ignored
|
||||
run: cargo test --workspace --verbose --no-default-features --features=crossterm,macros -- --ignored
|
||||
|
||||
clippy:
|
||||
name: clippy
|
||||
|
@ -92,4 +92,4 @@ jobs:
|
|||
uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --no-default-features --features=crossterm --workspace --bins --examples
|
||||
args: --no-default-features --features=crossterm,macros --workspace --bins --examples
|
||||
|
|
5
.github/workflows/default.yml
vendored
5
.github/workflows/default.yml
vendored
|
@ -67,13 +67,10 @@ jobs:
|
|||
- name: build_all
|
||||
run: cargo build --verbose --workspace
|
||||
|
||||
# doesn't use --include-ignored as it was unstable in 1.47
|
||||
# Don't test ignored as they require `macros` feature
|
||||
- name: test_regular
|
||||
run: cargo test --workspace --verbose
|
||||
|
||||
- name: test_ignored
|
||||
run: cargo test --workspace --verbose -- --ignored
|
||||
|
||||
rustfmt:
|
||||
name: rustfmt
|
||||
runs-on: ubuntu-18.04
|
||||
|
|
8
.github/workflows/termion.yml
vendored
8
.github/workflows/termion.yml
vendored
|
@ -54,14 +54,14 @@ jobs:
|
|||
|
||||
# build / doc / test
|
||||
- name: build_all
|
||||
run: cargo build --verbose --workspace --no-default-features --features=termion
|
||||
run: cargo build --verbose --workspace --no-default-features --features=termion,macros
|
||||
|
||||
# doesn't use --include-ignored as it was unstable in 1.47
|
||||
- name: test_regular
|
||||
run: cargo test --workspace --verbose --no-default-features --features=termion
|
||||
run: cargo test --workspace --verbose --no-default-features --features=termion,macros
|
||||
|
||||
- name: test_ignored
|
||||
run: cargo test --workspace --verbose --no-default-features --features=termion -- --ignored
|
||||
run: cargo test --workspace --verbose --no-default-features --features=termion,macros -- --ignored
|
||||
|
||||
clippy:
|
||||
name: clippy
|
||||
|
@ -81,4 +81,4 @@ jobs:
|
|||
uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --no-default-features --features=termion --workspace --bins --examples
|
||||
args: --no-default-features --features=termion,macros --workspace --bins --examples
|
||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -14,7 +14,7 @@ members = [
|
|||
[dependencies]
|
||||
tempfile = "3"
|
||||
ui = { package = "requestty-ui", path = "./requestty-ui" }
|
||||
macros = { package = "requestty-macros", path = "./requestty-macros" }
|
||||
macros = { package = "requestty-macros", path = "./requestty-macros", optional = true }
|
||||
|
||||
smallvec = { version = "1.6", optional = true }
|
||||
|
||||
|
@ -36,3 +36,11 @@ termion = ["ui/termion"]
|
|||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[[example]]
|
||||
name = "macros"
|
||||
required-features = ["macros"]
|
||||
|
||||
[[test]]
|
||||
name = "macros"
|
||||
required-features = ["macros"]
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -25,11 +25,12 @@
|
|||
//!
|
||||
//! See [`Question`] for more information on the builders.
|
||||
//!
|
||||
//! ### Using macros
|
||||
//! ### Using macros (only with `macros` feature)
|
||||
//!
|
||||
//! Unlike the builder api, the macros can only be used to create a list of questions.
|
||||
//!
|
||||
//! ```
|
||||
#![cfg_attr(feature = "macros", doc = "```")]
|
||||
#![cfg_attr(not(feature = "macros"), doc = "```ignore")]
|
||||
//! use requestty::{questions, Answers};
|
||||
//!
|
||||
//! let questions = questions! [
|
||||
|
@ -101,6 +102,9 @@
|
|||
//!
|
||||
//! # Optional features
|
||||
//!
|
||||
//! - `macros`: Enabling this feature will allow you to use the [`questions`] and
|
||||
//! [`prompt_module`](prompt_module!) macros.
|
||||
//!
|
||||
//! - `smallvec` (default): Enabling this feature will use [`SmallVec`] instead of [`Vec`] for [auto
|
||||
//! completions]. This allows inlining single completions.
|
||||
//!
|
||||
|
@ -208,6 +212,8 @@ use ui::{backend::Backend, events::EventIterator};
|
|||
/// Note that inlining only works for rust version 1.51 onwards. Pre 1.51, a [`Vec`] is still used.
|
||||
///
|
||||
/// See also [`prompt_module`](prompt_module!).
|
||||
#[cfg(feature = "macros")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
|
||||
pub use macros::questions;
|
||||
|
||||
pub use answer::{Answer, Answers, ExpandItem, ListItem};
|
||||
|
|
|
@ -168,6 +168,8 @@ where
|
|||
/// See also [`questions`].
|
||||
///
|
||||
/// [`questions`]: crate::questions
|
||||
#[cfg(feature = "macros")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
|
||||
#[macro_export]
|
||||
macro_rules! prompt_module {
|
||||
($($tt:tt)*) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user