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;
|
||||
pub struct Params {
|
||||
pub delimiter: String,
|
||||
pub source: String,
|
||||
pub compared: String,
|
||||
pub column: usize,
|
||||
pub output: String,
|
||||
delimiter: String,
|
||||
source: String,
|
||||
compared: String,
|
||||
column: usize,
|
||||
output: String,
|
||||
}
|
||||
|
||||
impl Params {
|
||||
|
@ -24,6 +24,26 @@ pub mod csv_compare {
|
|||
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 {
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -9,8 +9,8 @@ fn main() {
|
|||
let matches = App::from_yaml(yaml).get_matches();
|
||||
let params = Params::new_from_matches(matches);
|
||||
|
||||
let file = File::open(¶ms.source).unwrap();
|
||||
let file2 = File::open(¶ms.compared).unwrap();
|
||||
let file = File::open(¶ms.source()).unwrap();
|
||||
let file2 = File::open(¶ms.compared()).unwrap();
|
||||
|
||||
let reader = BufReader::new(file);
|
||||
let reader2 = BufReader::new(file2);
|
||||
|
@ -23,13 +23,13 @@ fn main() {
|
|||
load_vector(&mut vec2, reader2);
|
||||
|
||||
for i in vec1.iter() {
|
||||
let splitter: Vec<&str> = i.line.split(¶ms.delimiter).collect();
|
||||
let value = splitter[params.column];
|
||||
let splitter: Vec<&str> = i.line.split(params.delimiter()).collect();
|
||||
let value = splitter[params.column()];
|
||||
|
||||
let found = !matches!(
|
||||
vec2.iter().position(|r| {
|
||||
let splitter_b: Vec<&str> = r.line.split(¶ms.delimiter).collect();
|
||||
let search = splitter_b[params.column];
|
||||
let splitter_b: Vec<&str> = r.line.split(params.delimiter()).collect();
|
||||
let search = splitter_b[params.column()];
|
||||
search == value
|
||||
}),
|
||||
None
|
||||
|
@ -40,7 +40,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
if params.output.is_empty() == false {
|
||||
if params.output().is_empty() == false {
|
||||
write_to_file(params, diff);
|
||||
} else {
|
||||
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