Skip to content

Commit 1adbe01

Browse files
committed
Add hide option to exclude a column from the output
1 parent b80ecd6 commit 1adbe01

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct Column<'a> {
4949
path: String,
5050
value: RefCell<String>,
5151
attr: Option<&'a str>,
52+
hide: bool,
5253
filter: Option<Regex>,
5354
convert: Option<&'a str>,
5455
find: Option<&'a str>,
@@ -127,6 +128,7 @@ fn add_table<'a>(rowpath: &str, outfile: Option<&str>, filemode: &str, skip: Opt
127128
Some(add_table(&path, Some(file), filemode, skip, col["cols"].as_vec().expect("Subtable 'cols' entry is not an array")))
128129
}
129130
};
131+
let hide = col["hide"].as_bool().unwrap_or(false);
130132
let filter: Option<Regex> = col["filt"].as_str().map(|str| Regex::new(str).expect("Invalid regex in 'filt' entry in configuration file"));
131133
let attr = col["attr"].as_str();
132134
let convert = col["conv"].as_str();
@@ -149,7 +151,7 @@ fn add_table<'a>(rowpath: &str, outfile: Option<&str>, filemode: &str, skip: Opt
149151
}
150152
}
151153

152-
let column = Column { name: name.to_string(), path, value: RefCell::new(String::new()), attr, filter, convert, find, replace, consol, subtable };
154+
let column = Column { name: name.to_string(), path, value: RefCell::new(String::new()), attr, hide, filter, convert, find, replace, consol, subtable };
153155
table.columns.push(column);
154156
}
155157
table
@@ -390,7 +392,7 @@ fn main() -> std::io::Result<()> {
390392

391393
// Now write out the other column values
392394
for i in 0..table.columns.len() {
393-
if table.columns[i].subtable.is_some() { continue; }
395+
if table.columns[i].hide || table.columns[i].subtable.is_some() { continue; }
394396
if i > 0 { table.write("\t"); }
395397
if table.columns[i].value.borrow().is_empty() { table.write("\\N"); }
396398
else {

0 commit comments

Comments
 (0)