Skip to content

Commit

Permalink
Merge pull request #670 from figsoda/derive
Browse files Browse the repository at this point in the history
Add derive feature that reexports rustyline-derive's API
  • Loading branch information
gwenn authored Jan 18, 2023
2 parents b53e105 + 976853a commit 74c793e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 11 deletions.
21 changes: 16 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ memchr = "2.0"
# For custom bindings
radix_trie = { version = "0.2", optional = true }
regex = { version = "1.5.5", optional = true }
# For derive
rustyline-derive = { version = "0.7.0", optional = true, path = "rustyline-derive" }

[target.'cfg(unix)'.dependencies]
nix = { version = "0.26", default-features = false, features = ["fs", "ioctl", "poll", "signal", "term"] }
Expand All @@ -57,11 +59,11 @@ env_logger = { version = "0.10", default-features = false }
tempfile = "3.1.0"
rand = "0.8"
assert_matches = "1.2"
rustyline-derive = { version = "0.7.0", path = "rustyline-derive" }

[features]
default = ["custom-bindings", "with-dirs", "with-file-history"]
custom-bindings = ["radix_trie"]
derive = ["rustyline-derive"]
with-dirs = ["dirs-next"]
with-file-history = ["fd-lock"]
with-sqlite-history = ["rusqlite"]
Expand All @@ -70,22 +72,31 @@ case_insensitive_history_search = ["regex"]

[[example]]
name = "custom_key_bindings"
required-features = ["custom-bindings"]
required-features = ["custom-bindings", "derive"]
[[example]]
name = "diy_hints"
required-features = ["derive"]
[[example]]
name = "example"
required-features = ["custom-bindings"]
required-features = ["custom-bindings", "derive"]
[[example]]
name = "input_multiline"
required-features = ["custom-bindings"]
required-features = ["custom-bindings", "derive"]
[[example]]
name = "input_validation"
required-features = ["derive"]
[[example]]
name = "numeric_input"
required-features = ["custom-bindings"]
[[example]]
name = "read_password"
required-features = ["derive"]
[[example]]
name = "sqlite_history"
required-features = ["with-sqlite-history"]

[package.metadata.docs.rs]
features = ["custom-bindings", "with-dirs", "with-file-history", "with-fuzzy"]
features = ["custom-bindings", "derive", "with-dirs", "with-file-history", "with-fuzzy"]
all-features = false
no-default-features = true
default-target = "x86_64-unknown-linux-gnu"
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_key_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustyline::{
Cmd, ConditionalEventHandler, Editor, Event, EventContext, EventHandler, KeyEvent, RepeatCount,
Result,
};
use rustyline_derive::{Completer, Helper, Hinter, Validator};
use rustyline::{Completer, Helper, Hinter, Validator};

#[derive(Completer, Helper, Hinter, Validator)]
struct MyHelper(#[rustyline(Hinter)] HistoryHinter);
Expand Down
2 changes: 1 addition & 1 deletion examples/diy_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::collections::HashSet;
use rustyline::hint::{Hint, Hinter};
use rustyline::history::DefaultHistory;
use rustyline::Context;
use rustyline::{Completer, Helper, Highlighter, Validator};
use rustyline::{Editor, Result};
use rustyline_derive::{Completer, Helper, Highlighter, Validator};

#[derive(Completer, Helper, Validator, Highlighter)]
struct DIYHinter {
Expand Down
2 changes: 1 addition & 1 deletion examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustyline::highlight::{Highlighter, MatchingBracketHighlighter};
use rustyline::hint::HistoryHinter;
use rustyline::validate::MatchingBracketValidator;
use rustyline::{Cmd, CompletionType, Config, EditMode, Editor, KeyEvent};
use rustyline_derive::{Completer, Helper, Hinter, Validator};
use rustyline::{Completer, Helper, Hinter, Validator};

#[derive(Helper, Completer, Hinter, Validator)]
struct MyHelper {
Expand Down
2 changes: 1 addition & 1 deletion examples/input_multiline.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustyline::validate::MatchingBracketValidator;
use rustyline::{Cmd, Editor, EventHandler, KeyCode, KeyEvent, Modifiers, Result};
use rustyline_derive::{Completer, Helper, Highlighter, Hinter, Validator};
use rustyline::{Completer, Helper, Highlighter, Hinter, Validator};

#[derive(Completer, Helper, Highlighter, Hinter, Validator)]
struct InputValidator {
Expand Down
2 changes: 1 addition & 1 deletion examples/input_validation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustyline::validate::{ValidationContext, ValidationResult, Validator};
use rustyline::{Completer, Helper, Highlighter, Hinter};
use rustyline::{Editor, Result};
use rustyline_derive::{Completer, Helper, Highlighter, Hinter};

#[derive(Completer, Helper, Highlighter, Hinter)]
struct InputValidator {}
Expand Down
2 changes: 1 addition & 1 deletion examples/read_password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::borrow::Cow::{self, Borrowed, Owned};
use rustyline::config::Configurer;
use rustyline::highlight::Highlighter;
use rustyline::{ColorMode, Editor, Result};
use rustyline_derive::{Completer, Helper, Hinter, Validator};
use rustyline::{Completer, Helper, Hinter, Validator};

#[derive(Completer, Helper, Hinter, Validator)]
struct MaskingHighlighter {
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ use std::path::Path;
use std::result;

use log::debug;
#[cfg(feature = "derive")]
#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
pub use rustyline_derive::{Completer, Helper, Highlighter, Hinter, Validator};
use unicode_width::UnicodeWidthStr;

use crate::tty::{RawMode, RawReader, Renderer, Term, Terminal};
Expand Down

0 comments on commit 74c793e

Please sign in to comment.