diff --git a/README.md b/README.md index 4baaac9..5bf941d 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,22 @@ WILL OUPUT: ebook.pdf | Title + + + + + + + + + + --- [I am using Github under protest](protest.md) + +TODO: +---- + +[ ] use non-dashed approach to cli (rwxrob/bonzai) diff --git a/src/input.rs b/src/input.rs new file mode 100644 index 0000000..1dc7283 --- /dev/null +++ b/src/input.rs @@ -0,0 +1,21 @@ + +type Column = Vec; +type Columns = Vec; + +// split input text into columns based on separator character +// returns a type representing a variable length array of strings (columns) ? +pub fn split_columns(text: &str, sep: char) -> Option { + + Some(Columns::new()) +} + +#[test] +fn test_split_columns(){ + let coltext1 = r###" +file1.txt title1 +file2.pdf title2 +file3 title3 + "###; + let columns = split_columns(coltext1, '\t'); + println!("columns:\n{:?}", columns); +} diff --git a/src/main.rs b/src/main.rs index 9d11ca5..1ee1178 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ /* TODO: * 1. add clap for CLI flags - * 2. read input as column fields + * 2. read input as column field1920s * 3. test splitting input into fields * 4. execute arbitrary shell commands to manipulate input */ @@ -8,6 +8,8 @@ use clap::{Parser}; use std::process; +mod input; + #[derive(Parser)] #[command(name="colmap")] @@ -42,10 +44,11 @@ fn main() { // 1. parse cli parameters // 2. read from stdin - // 3. execute every field command on it's corresponding - // column + // 3. split stdin into columns (column/awk commands) + // 3. execute every field command on it's corresponding column + // [ ] execute a command on first text column // 4. print resulting concatenated columns - + if let None = cli.f1.as_deref() { eprintln!("no field --fX to operate on"); @@ -56,5 +59,7 @@ fn main() { println!("{:?}", cli.separator.unwrap()); println!("{:?}", cli.f1.unwrap()); } + + }