implemented getters
parent
1fd2169a5f
commit
3d670c84f0
30
src/lib.rs
30
src/lib.rs
|
@ -7,11 +7,11 @@ pub mod csv_compare {
|
||||||
|
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
pub struct Params {
|
pub struct Params {
|
||||||
pub delimiter: String,
|
delimiter: String,
|
||||||
pub source: String,
|
source: String,
|
||||||
pub compared: String,
|
compared: String,
|
||||||
pub column: usize,
|
column: usize,
|
||||||
pub output: String,
|
output: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Params {
|
impl Params {
|
||||||
|
@ -24,6 +24,26 @@ pub mod csv_compare {
|
||||||
output: matches.value_of("output").unwrap().to_string(),
|
output: matches.value_of("output").unwrap().to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn delimiter(&self) -> &String {
|
||||||
|
&self.delimiter
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn source(&self) -> &String {
|
||||||
|
&self.source
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn compared(&self) -> &String {
|
||||||
|
&self.compared
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn output(&self) -> &String {
|
||||||
|
&self.output
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn column(&self) -> usize {
|
||||||
|
self.column
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CsvLine {
|
pub struct CsvLine {
|
||||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -9,8 +9,8 @@ fn main() {
|
||||||
let matches = App::from_yaml(yaml).get_matches();
|
let matches = App::from_yaml(yaml).get_matches();
|
||||||
let params = Params::new_from_matches(matches);
|
let params = Params::new_from_matches(matches);
|
||||||
|
|
||||||
let file = File::open(¶ms.source).unwrap();
|
let file = File::open(¶ms.source()).unwrap();
|
||||||
let file2 = File::open(¶ms.compared).unwrap();
|
let file2 = File::open(¶ms.compared()).unwrap();
|
||||||
|
|
||||||
let reader = BufReader::new(file);
|
let reader = BufReader::new(file);
|
||||||
let reader2 = BufReader::new(file2);
|
let reader2 = BufReader::new(file2);
|
||||||
|
@ -23,13 +23,13 @@ fn main() {
|
||||||
load_vector(&mut vec2, reader2);
|
load_vector(&mut vec2, reader2);
|
||||||
|
|
||||||
for i in vec1.iter() {
|
for i in vec1.iter() {
|
||||||
let splitter: Vec<&str> = i.line.split(¶ms.delimiter).collect();
|
let splitter: Vec<&str> = i.line.split(params.delimiter()).collect();
|
||||||
let value = splitter[params.column];
|
let value = splitter[params.column()];
|
||||||
|
|
||||||
let found = !matches!(
|
let found = !matches!(
|
||||||
vec2.iter().position(|r| {
|
vec2.iter().position(|r| {
|
||||||
let splitter_b: Vec<&str> = r.line.split(¶ms.delimiter).collect();
|
let splitter_b: Vec<&str> = r.line.split(params.delimiter()).collect();
|
||||||
let search = splitter_b[params.column];
|
let search = splitter_b[params.column()];
|
||||||
search == value
|
search == value
|
||||||
}),
|
}),
|
||||||
None
|
None
|
||||||
|
@ -40,7 +40,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if params.output.is_empty() == false {
|
if params.output().is_empty() == false {
|
||||||
write_to_file(params, diff);
|
write_to_file(params, diff);
|
||||||
} else {
|
} else {
|
||||||
print_lines(diff);
|
print_lines(diff);
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue