Skip to content

Commit

Permalink
Move definitions runner related functions
Browse files Browse the repository at this point in the history
fn runner() and fn from_cli(cli: Cli) util functions are located to
app.rs. However, those are utils for runner. So this commit change the
functions to runner.rs.
  • Loading branch information
sux2mfgj authored and sayanarijit committed Oct 17, 2021
1 parent a3b400d commit 13d046e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/run.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
match xplr::app::runner().and_then(|a| a.run()) {
match xplr::runner::runner().and_then(|a| a.run()) {
Ok(Some(out)) => print!("{}", out),
Ok(None) => {}
Err(err) => {
Expand Down
12 changes: 0 additions & 12 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use crate::cli::Cli;
use crate::config::Config;
use crate::config::Mode;
use crate::explorer;
use crate::input::Key;
use crate::lua;
use crate::permissions::Permissions;
use crate::runner::Runner;
use crate::ui::Layout;
use anyhow::{bail, Result};
use chrono::{DateTime, Local};
Expand Down Expand Up @@ -2537,13 +2535,3 @@ impl App {
}
}
}

/// Create a new runner object passing the default arguments
pub fn runner() -> Result<Runner> {
Runner::new()
}

/// Create a new runner object passing the given arguments
pub fn from_cli(cli: Cli) -> Result<Runner> {
Runner::from_cli(cli)
}
4 changes: 2 additions & 2 deletions src/bin/xplr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use std::env;

use xplr::app;
use xplr::cli::Cli;
use xplr::runner;

fn main() {
let cli = Cli::parse(env::args()).unwrap_or_else(|e| {
Expand Down Expand Up @@ -47,7 +47,7 @@ fn main() {
} else if cli.version {
println!("xplr {}", xplr::app::VERSION);
} else {
match app::from_cli(cli).and_then(|a| a.run()) {
match runner::from_cli(cli).and_then(|a| a.run()) {
Ok(Some(out)) => print!("{}", out),
Ok(None) => {}
Err(err) => {
Expand Down
10 changes: 10 additions & 0 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,13 @@ impl Runner {
result
}
}

/// Create a new runner object passing the default arguments
pub fn runner() -> Result<Runner> {
Runner::new()
}

/// Create a new runner object passing the given arguments
pub fn from_cli(cli: Cli) -> Result<Runner> {
Runner::from_cli(cli)
}

0 comments on commit 13d046e

Please sign in to comment.