Fix clippy warnings and publish 0.5.0

This commit is contained in:
Lutetium-Vanadium 2022-09-01 18:49:34 +05:30
parent e27b63b5cf
commit c454826c25
12 changed files with 59 additions and 35 deletions

View File

@ -1,13 +1,32 @@
# Changelog
## `0.4.1`
## `0.5.0`
## `0.4.0`
- `requestty`
- Update the way indices are shown in `RawSelect`
- Added `OrderSelect` (#16)
- [bug fix] Support multi-word editor commands (#14)
- `requestty-ui`
- [bug fix] Add support for rendering wide characters. (#18, #19 and
#20)
- [bug fix] Show message when prompt's height exceeds the terminal
height. Earlier, it would panic in debug builds due to overflow.
(#17)
## `0.4.1`
- `requestty-ui`
- Remove `dbg!` in `Input`. Fixes #12
## `0.4.0`
The msrv has been bumped up to `1.56`
- `requestty`

View File

@ -1,6 +1,6 @@
[package]
name = "requestty"
version = "0.4.1"
version = "0.5.0"
authors = ["Lutetium Vanadium"]
edition = "2018"
description = "An easy-to-use collection of interactive cli prompts"
@ -21,8 +21,8 @@ members = [
]
[dependencies]
ui = { package = "requestty-ui", path = "./requestty-ui", version = "=0.4.1" }
macro = { package = "requestty-macro", path = "./requestty-macro", optional = true, version = "=0.4.1" }
ui = { package = "requestty-ui", path = "./requestty-ui", version = "=0.5.0" }
macro = { package = "requestty-macro", path = "./requestty-macro", optional = true, version = "=0.5.0" }
tempfile = "3"

View File

@ -132,6 +132,12 @@ There are 11 in-built prompts:
<img src="./assets/multi-select.gif" style="max-height: 20rem" />
- ### OrderSelect
Prompt that allows the user to organize a list of options.
<img src="./assets/order-select.gif" style="max-height: 20rem" />
## Optional features
- `macros`: Enabling this feature will allow you to use the `questions`

View File

@ -41,11 +41,11 @@ fn auto_complete(p: String) -> Completions<String> {
if files.is_empty() {
return completions![p];
} else {
let fuzzer = SkimMatcherV2::default();
files.sort_by_cached_key(|file| fuzzer.fuzzy_match(file, last).unwrap_or(i64::MAX));
files
}
let fuzzer = SkimMatcherV2::default();
files.sort_by_cached_key(|file| fuzzer.fuzzy_match(file, last).unwrap_or(i64::MAX));
files
}
fn main() {

View File

@ -1,6 +1,6 @@
[package]
name = "requestty-macro"
version = "0.4.1"
version = "0.5.0"
authors = ["Lutetium Vanadium"]
edition = "2018"
description = "The `questions` macro for `requestty`"

View File

@ -1,6 +1,6 @@
[package]
name = "requestty-ui"
version = "0.4.1"
version = "0.5.0"
authors = ["Lutetium Vanadium"]
edition = "2018"
description = "A widget based terminal ui rendering library."

View File

@ -45,8 +45,7 @@ fn split(command: &str) -> Option<Vec<String>> {
fn get_editor() -> Command {
let editor_args = env::var_os("VISUAL")
.or_else(|| env::var_os("EDITOR"))
.map(|editor_command| editor_command.to_str().map(split))
.flatten()
.and_then(|editor_command| editor_command.to_str().map(split))
.flatten()
.unwrap_or_else(|| {
if cfg!(windows) {

View File

@ -18,9 +18,9 @@ macro_rules! impl_filter_builder {
$(#[$meta])+
pub fn filter<F>(mut self, filter: F) -> Self
where
F: FnOnce($t, &crate::Answers) -> $t + 'a,
F: FnOnce($t, &$crate::Answers) -> $t + 'a,
{
self.$inner.filter = crate::question::Filter::Sync(Box::new(filter));
self.$inner.filter = $crate::question::Filter::Sync(Box::new(filter));
self
}
};
@ -56,10 +56,10 @@ macro_rules! impl_auto_complete_builder {
$(#[$meta])+
pub fn auto_complete<F>(mut self, auto_complete: F) -> Self
where
F: FnMut($t, &crate::Answers) -> Completions<$t> + 'a,
F: FnMut($t, &$crate::Answers) -> Completions<$t> + 'a,
{
self.$inner.auto_complete =
crate::question::AutoComplete::Sync(Box::new(auto_complete));
$crate::question::AutoComplete::Sync(Box::new(auto_complete));
self
}
};
@ -69,11 +69,11 @@ macro_rules! impl_auto_complete_builder {
#[macro_export]
macro_rules! impl_validate_builder {
($(#[$meta:meta])+ $t:ty; $inner:ident) => {
crate::impl_validate_builder!($(#[$meta])* impl &$t; $inner Validate);
$crate::impl_validate_builder!($(#[$meta])* impl &$t; $inner Validate);
};
($(#[$meta:meta])+ by val $t:ty; $inner:ident) => {
crate::impl_validate_builder!($(#[$meta])* impl $t; $inner ValidateByVal);
$crate::impl_validate_builder!($(#[$meta])* impl $t; $inner ValidateByVal);
};
// NOTE: the 2 extra lines at the end of each doc comment is intentional -- it makes sure that
@ -93,9 +93,9 @@ macro_rules! impl_validate_builder {
$(#[$meta])*
pub fn validate<F>(mut self, filter: F) -> Self
where
F: FnMut($t, &crate::Answers) -> Result<(), String> + 'a,
F: FnMut($t, &$crate::Answers) -> Result<(), String> + 'a,
{
self.$inner.validate = crate::question::$handler::Sync(Box::new(filter));
self.$inner.validate = $crate::question::$handler::Sync(Box::new(filter));
self
}
};
@ -105,11 +105,11 @@ macro_rules! impl_validate_builder {
#[macro_export]
macro_rules! impl_validate_on_key_builder {
($(#[$meta:meta])+ $t:ty; $inner:ident) => {
crate::impl_validate_on_key_builder!($(#[$meta])* impl &$t; $inner ValidateOnKey);
$crate::impl_validate_on_key_builder!($(#[$meta])* impl &$t; $inner ValidateOnKey);
};
($(#[$meta:meta])+ by val $t:ty; $inner:ident) => {
crate::impl_validate_on_key_builder!($(#[$meta])* impl $t; $inner ValidateOnKeyByVal);
$crate::impl_validate_on_key_builder!($(#[$meta])* impl $t; $inner ValidateOnKeyByVal);
};
// NOTE: the 2 extra lines at the end of each doc comment is intentional -- it makes sure that
@ -133,9 +133,9 @@ macro_rules! impl_validate_on_key_builder {
$(#[$meta])*
pub fn validate_on_key<F>(mut self, filter: F) -> Self
where
F: FnMut($t, &crate::Answers) -> bool + 'a,
F: FnMut($t, &$crate::Answers) -> bool + 'a,
{
self.$inner.validate_on_key = crate::question::$handler::Sync(Box::new(filter));
self.$inner.validate_on_key = $crate::question::$handler::Sync(Box::new(filter));
self
}
};
@ -145,11 +145,11 @@ macro_rules! impl_validate_on_key_builder {
#[macro_export]
macro_rules! impl_transform_builder {
($(#[$meta:meta])+ $t:ty; $inner:ident) => {
crate::impl_transform_builder!($(#[$meta])* impl &$t; $inner Transform);
$crate::impl_transform_builder!($(#[$meta])* impl &$t; $inner Transform);
};
($(#[$meta:meta])+ by val $t:ty; $inner:ident) => {
crate::impl_transform_builder!($(#[$meta])* impl $t; $inner TransformByVal);
$crate::impl_transform_builder!($(#[$meta])* impl $t; $inner TransformByVal);
};
// NOTE: the 2 extra lines at the end of each doc comment is intentional -- it makes sure that
@ -169,9 +169,9 @@ macro_rules! impl_transform_builder {
$(#[$meta])*
pub fn transform<F>(mut self, transform: F) -> Self
where
F: FnOnce($t, &crate::Answers, &mut dyn Backend) -> std::io::Result<()> + 'a,
F: FnOnce($t, &$crate::Answers, &mut dyn Backend) -> std::io::Result<()> + 'a,
{
self.$inner.transform = crate::question::$handler::Sync(Box::new(transform));
self.$inner.transform = $crate::question::$handler::Sync(Box::new(transform));
self
}
};

View File

@ -52,7 +52,7 @@ impl Int<'_> {
}
fn filter_map(c: char) -> Option<char> {
if c.is_digit(10) || c == '-' || c == '+' {
if c.is_ascii_digit() || c == '-' || c == '+' {
Some(c)
} else {
None

View File

@ -48,7 +48,7 @@ macro_rules! impl_options_builder {
$(#[$message_meta])*
pub fn message<M>(mut self, message: M) -> Self
where
M: Into<crate::question::options::Getter<'a, String>>,
M: Into<$crate::question::options::Getter<'a, String>>,
{
self.opts.message = Some(message.into());
self
@ -68,7 +68,7 @@ macro_rules! impl_options_builder {
$(#[$when_meta])*
pub fn when<W>(mut self, when: W) -> Self
where
W: Into<crate::question::options::Getter<'a, bool>>,
W: Into<$crate::question::options::Getter<'a, bool>>,
{
self.opts.when = when.into();
self
@ -109,7 +109,7 @@ macro_rules! impl_options_builder {
$(#[$on_esc_meta])*
pub fn on_esc<T>(mut self, on_esc: T) -> Self
where
T: Into<crate::question::options::Getter<'a, ui::OnEsc>>,
T: Into<$crate::question::options::Getter<'a, ui::OnEsc>>,
{
self.opts.on_esc = on_esc.into();
self

View File

@ -253,7 +253,7 @@ impl Widget for OrderSelectPrompt<'_, '_> {
/// The representation of each choice in an [`OrderSelect`](crate::Question::order_select).
///
/// It is different from [`ListItem`](crate::answer::ListItem) due to an implementation detail.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OrderSelectItem {
pub(crate) initial_index: usize,
pub(crate) text: Text<String>,

View File

@ -199,7 +199,7 @@ impl<'a> RawSelect<'a> {
RawSelectPrompt {
input: widgets::StringInput::with_filter_map(|c| {
if c.is_digit(10) {
if c.is_ascii_digit() {
Some(c)
} else {
None