lib.rs is the library crate. The UI stuff (clap etc) should be in main.rs or one of its descendant modules.
Comment always have a space after the // | ///
e.g. -> /// Example Foo Bar โ ///Example Foo Bar โ
Edit: 3. You can add another argument to force file type to tsv or csv. Some files might have tsv or csv somewhere in file name or the file contents might be entered through stdin (you can add that too actually)
Edit: 4. To split the file into header, first line etc, instead of comparing the index, you should have a mutable iterator and use next.
let mut header = String::new();
let mut first_row = String::new();
let mut body = Vec::new();
for (x, line) in text.lines().enumerate() {
if x == 0 {
header = line.to_string()
};
if x == 1 {
first_row = line.to_string();
body.push(line.to_string())
};
if x > 1 {
body.push(line.to_string())
};
}
let mut contents = text.lines();
let header = contents.next().unwrap().to_string();
let first_row = contents.next().unwrap().to_string();
let body = contents.map(|l| l.to_string()).collect::<Vec<String>>();