Skip to content

Commit

Permalink
test: changes master -> (pr) for test_simple_struct
Browse files Browse the repository at this point in the history
  • Loading branch information
dj8yf0μl committed Feb 4, 2025
1 parent e9e96ab commit b1e5faa
Showing 1 changed file with 56 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,62 @@ pub struct CliArgs {
impl interactive_clap::ToCli for Args {
type CliVariant = CliArgs;
}
impl Args {
pub fn try_parse() -> Result<CliArgs, clap::Error> {
<CliArgs as clap::Parser>::try_parse()
}
pub fn parse() -> CliArgs {
<CliArgs as clap::Parser>::parse()
}
pub fn try_parse_from<I, T>(itr: I) -> Result<CliArgs, clap::Error>
where
I: ::std::iter::IntoIterator<Item = T>,
T: ::std::convert::Into<::std::ffi::OsString> + ::std::clone::Clone,
{
<CliArgs as clap::Parser>::try_parse_from(itr)
}
}
impl From<Args> for CliArgs {
fn from(args: Args) -> Self {
Self {
age: Some(args.age.into()),
first_name: Some(args.first_name.into()),
second_name: Some(args.second_name.into()),
}
}
}
impl Args {
fn input_age(_context: &()) -> color_eyre::eyre::Result<Option<u64>> {
match inquire::CustomType::new("age").prompt() {
Ok(value) => Ok(Some(value)),
Err(
inquire::error::InquireError::OperationCanceled
| inquire::error::InquireError::OperationInterrupted,
) => Ok(None),
Err(err) => Err(err.into()),
}
}
fn input_first_name(_context: &()) -> color_eyre::eyre::Result<Option<String>> {
match inquire::CustomType::new("first_name").prompt() {
Ok(value) => Ok(Some(value)),
Err(
inquire::error::InquireError::OperationCanceled
| inquire::error::InquireError::OperationInterrupted,
) => Ok(None),
Err(err) => Err(err.into()),
}
}
fn input_second_name(_context: &()) -> color_eyre::eyre::Result<Option<String>> {
match inquire::CustomType::new("second_name").prompt() {
Ok(value) => Ok(Some(value)),
Err(
inquire::error::InquireError::OperationCanceled
| inquire::error::InquireError::OperationInterrupted,
) => Ok(None),
Err(err) => Err(err.into()),
}
}
}
pub struct InteractiveClapContextScopeForArgs {
pub age: u64,
pub first_name: String,
Expand Down Expand Up @@ -81,57 +137,3 @@ impl interactive_clap::FromCli for Args {
interactive_clap::ResultFromCli::Ok(clap_variant)
}
}
impl Args {
fn input_age(_context: &()) -> color_eyre::eyre::Result<Option<u64>> {
match inquire::CustomType::new("age").prompt() {
Ok(value) => Ok(Some(value)),
Err(
inquire::error::InquireError::OperationCanceled
| inquire::error::InquireError::OperationInterrupted,
) => Ok(None),
Err(err) => Err(err.into()),
}
}
fn input_first_name(_context: &()) -> color_eyre::eyre::Result<Option<String>> {
match inquire::CustomType::new("first_name").prompt() {
Ok(value) => Ok(Some(value)),
Err(
inquire::error::InquireError::OperationCanceled
| inquire::error::InquireError::OperationInterrupted,
) => Ok(None),
Err(err) => Err(err.into()),
}
}
fn input_second_name(_context: &()) -> color_eyre::eyre::Result<Option<String>> {
match inquire::CustomType::new("second_name").prompt() {
Ok(value) => Ok(Some(value)),
Err(
inquire::error::InquireError::OperationCanceled
| inquire::error::InquireError::OperationInterrupted,
) => Ok(None),
Err(err) => Err(err.into()),
}
}
pub fn try_parse() -> Result<CliArgs, clap::Error> {
<CliArgs as clap::Parser>::try_parse()
}
pub fn parse() -> CliArgs {
<CliArgs as clap::Parser>::parse()
}
pub fn try_parse_from<I, T>(itr: I) -> Result<CliArgs, clap::Error>
where
I: ::std::iter::IntoIterator<Item = T>,
T: ::std::convert::Into<::std::ffi::OsString> + ::std::clone::Clone,
{
<CliArgs as clap::Parser>::try_parse_from(itr)
}
}
impl From<Args> for CliArgs {
fn from(args: Args) -> Self {
Self {
age: Some(args.age.into()),
first_name: Some(args.first_name.into()),
second_name: Some(args.second_name.into()),
}
}
}

0 comments on commit b1e5faa

Please sign in to comment.