Skip to content

Commit

Permalink
renamed: initial_str_value to starting_input, with_initial_str_value …
Browse files Browse the repository at this point in the history
…to with_starting_input
  • Loading branch information
FroVolod committed Dec 27, 2023
1 parent 085ae5c commit e59ee39
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- Ctrl-b/Ctrl-f for left/right
- Ctrl-j/Ctrl-g for enter/cancel
- Added 'with_starting_filter_input' to both Select and MultiSelect, which allows for setting an initial value to the filter section of the prompt.
- **Breaking** Added initial_str_value for CustomType. [#194](https://github.com/mikaelmello/inquire/pull/194)
- Added starting_input for CustomType. [#194](https://github.com/mikaelmello/inquire/pull/194)

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion inquire/examples/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() {

let ans = Confirm {
message: "Are you happy?",
initial_str_value: None,
starting_input: None,
default: Some(false),
placeholder: Some("si|no"),
help_message: Some("It's alright if you're not"),
Expand Down
2 changes: 1 addition & 1 deletion inquire/examples/custom_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use inquire::{validator::Validation, CustomType};

fn main() {
let amount = CustomType::<f64>::new("How much do you want to donate?")
.with_initial_str_value("10.00")
.with_starting_input("10.00")
.with_formatter(&|i| format!("${i:.2}"))
.with_error_message("Please type a valid number")
.with_help_message("Type the amount in US dollars using a decimal point as a separator")
Expand Down
10 changes: 5 additions & 5 deletions inquire/src/prompts/confirm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub struct Confirm<'a> {
/// If you want to set a default value for the prompt, returned when the user's submission is empty, see [`default`].
///
/// [`default`]: Self::default
pub initial_str_value: Option<&'a str>,
pub starting_input: Option<&'a str>,

/// Default value, returned when the user input is empty.
pub default: Option<bool>,
Expand Down Expand Up @@ -122,7 +122,7 @@ impl<'a> Confirm<'a> {
pub fn new(message: &'a str) -> Self {
Self {
message,
initial_str_value: None,
starting_input: None,
default: None,
placeholder: None,
help_message: None,
Expand All @@ -139,8 +139,8 @@ impl<'a> Confirm<'a> {
/// If you want to set a default value for the prompt, returned when the user's submission is empty, see [`with_default`].
///
/// [`with_default`]: Self::with_default
pub fn with_initial_str_value(mut self, message: &'a str) -> Self {
self.initial_str_value = Some(message);
pub fn with_starting_input(mut self, message: &'a str) -> Self {
self.starting_input = Some(message);
self
}

Expand Down Expand Up @@ -242,7 +242,7 @@ impl<'a> From<Confirm<'a>> for CustomType<'a, bool> {
fn from(co: Confirm<'a>) -> Self {
Self {
message: co.message,
initial_str_value: co.initial_str_value,
starting_input: co.starting_input,
default: co.default,
default_value_formatter: co.default_value_formatter,
placeholder: co.placeholder,
Expand Down
10 changes: 5 additions & 5 deletions inquire/src/prompts/custom_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use self::prompt::CustomTypePrompt;
///
/// let amount_prompt: CustomType<f64> = CustomType {
/// message: "How much is your travel going to cost?",
/// initial_str_value: None,
/// starting_input: None,
/// formatter: &|i| format!("${:.2}", i),
/// default_value_formatter: &|i| format!("${:.2}", i),
/// default: None,
Expand Down Expand Up @@ -86,7 +86,7 @@ pub struct CustomType<'a, T> {
/// If you want to set a default value for the prompt, returned when the user's submission is empty, see [`default`].
///
/// [`default`]: Self::default
pub initial_str_value: Option<&'a str>,
pub starting_input: Option<&'a str>,

/// Default value, returned when the user input is empty.
pub default: Option<T>,
Expand Down Expand Up @@ -142,7 +142,7 @@ where
{
Self {
message,
initial_str_value: None,
starting_input: None,
default: None,
placeholder: None,
help_message: None,
Expand All @@ -160,8 +160,8 @@ where
/// If you want to set a default value for the prompt, returned when the user's submission is empty, see [`with_default`].
///
/// [`with_default`]: Self::with_default
pub fn with_initial_str_value(mut self, message: &'a str) -> Self {
self.initial_str_value = Some(message);
pub fn with_starting_input(mut self, message: &'a str) -> Self {
self.starting_input = Some(message);
self
}

Expand Down
2 changes: 1 addition & 1 deletion inquire/src/prompts/custom_type/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
T: Clone,
{
fn from(co: CustomType<'a, T>) -> Self {
let input = Input::new_with(co.initial_str_value.unwrap_or_default());
let input = Input::new_with(co.starting_input.unwrap_or_default());
let input = if let Some(placeholder) = co.placeholder {
input.with_placeholder(placeholder)
} else {
Expand Down

0 comments on commit e59ee39

Please sign in to comment.