Skip to content

Commit b4dd82c

Browse files
committed
Started fixing it
1 parent 4fdf0f4 commit b4dd82c

File tree

6 files changed

+13
-34
lines changed

6 files changed

+13
-34
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ src/main.exe
22
src/main.pdb
33

44
/target
5+
6+
.idea

Cargo.lock

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
[package]
22
name = "searcher_txt"
3-
version = "1.0.0"
3+
version = "1.1.0"
44
authors = ["Raphdf201 <deschenesr545@gmail.com>"]
55
edition = "2021"
6-
license-file = "LICENSE.txt"
6+
license = "unlicense"
77
description = "A copy of grep that i mate to train my rust skills"
88
readme = "README.md"
99
homepage = "https://github.com/Raphdf201/minigrep/releases"
1010
repository = "https://github.com/Raphdf201/minigrep"
1111
keywords = ["cli", "grep", "search"]
1212

1313
[dependencies]
14-
anyhow = "1.0"
1514

1615
[profile.dev]
1716
opt-level = 0

LICENSE.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use std::env;
22
use std::fmt::Result;
33
use std::fs;
44

5-
use anyhow::Error;
6-
7-
pub fn run(config: Config) -> Result {
5+
pub fn run(config: ()) -> Result {
86
let contents = fs::read_to_string(config.filename)?;
97

108
let results = if config.case_sensitive {
@@ -27,9 +25,9 @@ pub struct Config {
2725
}
2826

2927
impl Config {
30-
pub fn new(args: &[String]) -> Result<Config, Error> {
28+
pub fn new(args: &[String]) -> Result {
3129
if args.len() < 3 {
32-
return Err(Error::msg("Not enough arguments"));
30+
return Err(core::fmt::Error::msg("Not enough arguments"));
3331
}
3432
let query: String = args[1].clone();
3533
let filename: String = args[2].clone();

src/main.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
use std::env;
2-
use std::process;
3-
4-
use searcher_txt::run;
5-
use searcher_txt::Config;
2+
use std::fs;
63

74
fn main() {
85
let args: Vec<String> = env::args().collect();
96

10-
let config = Config::new(&args).unwrap_or_else(|err| {
11-
eprintln!("Problem parsing arguments : {}", err);
12-
process::exit(1)
13-
});
7+
let query = &args[1];
8+
let filename = &args[2];
9+
10+
let contents = fs::read_to_string(filename).expect("Error while reading the file");
1411

15-
println!("Searching for {}", config.query);
16-
println!("In file {}", config.filename);
1712

18-
if let Err(e) = run(config) {
19-
eprintln!("Application error : {}", e);
20-
process::exit(1);
21-
}
2213
}

0 commit comments

Comments
 (0)