-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved all the definitions into lib.rs
- Loading branch information
1 parent
cfc15b0
commit 756dcfc
Showing
2 changed files
with
25 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use std::{error::Error, fs}; | ||
|
||
pub fn run(config: Config) -> Result<(), Box<dyn Error>> { | ||
let content = fs::read_to_string(config.file_path)?; | ||
println!("Content:\n {}", content); | ||
Ok(()) | ||
} | ||
|
||
pub struct Config { | ||
pub query: String, | ||
pub file_path: String, | ||
} | ||
|
||
impl Config { | ||
pub fn build(args: &[String]) -> Result<Config, &'static str> { | ||
if args.len() < 3 { | ||
return Err("not enough arguments"); | ||
} | ||
let query = args[1].clone(); | ||
let file_path = args[2].clone(); | ||
Ok(Config { query, file_path }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters