From fc59c876061b712f40ebcb75fe07f917cfee855e Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Fri, 19 Feb 2021 00:40:53 -0800 Subject: [PATCH] this example now runs out of the box instead of failing with no value or the wrong value (#3067) --- crates/nu-table/src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/nu-table/src/main.rs b/crates/nu-table/src/main.rs index cb0f0ef45..f7bf1e11b 100644 --- a/crates/nu-table/src/main.rs +++ b/crates/nu-table/src/main.rs @@ -3,9 +3,18 @@ use std::collections::HashMap; fn main() { let args: Vec<_> = std::env::args().collect(); + let mut width = 0; + + if args.len() > 1 { + // Width in terminal characters + width = args[1].parse::().expect("Need a width in columns"); + } + + if width < 4 { + println!("Width must be greater than or equal to 4, setting width to 80"); + width = 80; + } - // Width in terminal characters - let width = args[1].parse::().expect("Need a width in columns"); // The mocked up table data let (table_headers, row_data) = make_table_data(); // The table headers