rsv_lib/
lib.rs

1mod args;
2mod csv_lib;
3mod excel_lib;
4mod general_lib;
5mod utils;
6
7use crate::utils::{file::is_excel, filename::full_path, return_result::CliResultData};
8
9// general
10pub use general_lib::size::file_size;
11
12// count
13use csv_lib::count::csv_count;
14use excel_lib::count::excel_count;
15pub fn file_count(file: &str, no_header: bool, sheet: usize) -> CliResultData {
16    let path = full_path(file);
17    match is_excel(&path) {
18        true => excel_count(&path, no_header, sheet),
19        false => csv_count(&path, no_header),
20    }
21}
22
23// head
24use csv_lib::head::csv_head;
25use excel_lib::head::excel_head;
26pub fn file_head(
27    file: &str,
28    no_header: bool,
29    sep: char,
30    quote: char,
31    sheet: usize,
32    n: usize,
33) -> CliResultData {
34    let path = full_path(file);
35    match is_excel(&path) {
36        true => excel_head(&path, no_header, sheet, n),
37        false => csv_head(&path, no_header, sep, quote, n),
38    }
39}
40
41// headers
42use csv_lib::headers::csv_headers;
43use excel_lib::headers::excel_headers;
44pub fn file_headers(file: &str, sep: char, quote: char, sheet: usize) -> CliResultData {
45    let path = full_path(file);
46    match is_excel(&path) {
47        true => excel_headers(&path, sheet),
48        false => csv_headers(&path, sep, quote),
49    }
50}