Skip to content

Commit

Permalink
refactor(app_builder): remove AppBuilder trait
Browse files Browse the repository at this point in the history
  • Loading branch information
icanvardar committed Nov 4, 2024
1 parent e16a812 commit 5e753e7
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions src/common/app_builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{error::Error, pin::Pin};
use std::error::Error;

use clap::Parser;

Expand All @@ -23,30 +23,23 @@ pub struct Args {
output: Option<String>,
}

pub trait AppBuilder {
fn build() -> Pin<Box<dyn core::future::Future<Output = Result<Arbor, Box<dyn Error>>> + Send>>
impl Arbor {
pub async fn build() -> Result<Arbor, Box<dyn Error>>
where
Self: Sync,
{
Box::pin(async move {
let args = Args::parse();

let output = if let Some(ref o) = args.output {
Some(o.as_str())
} else {
None
};

Ok(Arbor {
autocomplete: Autocomplete::build(
args.language.clone(),
args.thread_count,
args.max_suggestion,
args.backup,
output,
)
.await?,
})
let args = Args::parse();
let output = args.output.as_deref();

Ok(Arbor {
autocomplete: Autocomplete::build(
args.language.clone(),
args.thread_count,
args.max_suggestion,
args.backup,
output,
)
.await?,
})
}
}
Expand All @@ -55,8 +48,6 @@ pub struct Arbor {
pub autocomplete: Autocomplete,
}

impl AppBuilder for Arbor {}

#[cfg(test)]
mod tests {
use std::ffi::OsString;
Expand Down

0 comments on commit 5e753e7

Please sign in to comment.