From ba8383ae2fc129d95d2463241811f4ae6fea0773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 10 Sep 2019 07:00:25 -0500 Subject: [PATCH] to-[csv/tsv] fixes. --- src/commands/to_csv.rs | 10 ++++++++-- src/commands/to_tsv.rs | 8 +++++++- src/plugins/binaryview.rs | 2 +- tests/commands_test.rs | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/commands/to_csv.rs b/src/commands/to_csv.rs index 0d13cab8fc..615e49cbf8 100644 --- a/src/commands/to_csv.rs +++ b/src/commands/to_csv.rs @@ -37,6 +37,9 @@ pub fn value_to_csv_value(v: &Value) -> Value { Value::Primitive(Primitive::String(s)) => Value::Primitive(Primitive::String(s.clone())), Value::Primitive(Primitive::Nothing) => Value::Primitive(Primitive::Nothing), Value::Primitive(Primitive::Boolean(b)) => Value::Primitive(Primitive::Boolean(b.clone())), + Value::Primitive(Primitive::Decimal(f)) => Value::Primitive(Primitive::Decimal(f.clone())), + Value::Primitive(Primitive::Int(i)) => Value::Primitive(Primitive::Int(i.clone())), + Value::Primitive(Primitive::Path(x)) => Value::Primitive(Primitive::Path(x.clone())), Value::Primitive(Primitive::Bytes(b)) => Value::Primitive(Primitive::Bytes(b.clone())), Value::Primitive(Primitive::Date(d)) => Value::Primitive(Primitive::Date(d.clone())), Value::Row(o) => Value::Row(o.clone()), @@ -51,8 +54,11 @@ fn to_string_helper(v: &Value) -> Result { Value::Primitive(Primitive::Date(d)) => Ok(d.to_string()), Value::Primitive(Primitive::Bytes(b)) => Ok(format!("{}", b)), Value::Primitive(Primitive::Boolean(_)) => Ok(v.as_string()?), - Value::Table(_) => return Ok(String::from("[list list]")), - Value::Row(_) => return Ok(String::from("[object]")), + Value::Primitive(Primitive::Decimal(_)) => Ok(v.as_string()?), + Value::Primitive(Primitive::Int(_)) => Ok(v.as_string()?), + Value::Primitive(Primitive::Path(_)) => Ok(v.as_string()?), + Value::Table(_) => return Ok(String::from("[Table]")), + Value::Row(_) => return Ok(String::from("[Row]")), Value::Primitive(Primitive::String(s)) => return Ok(s.to_string()), _ => return Err(ShellError::string("Unexpected value")), } diff --git a/src/commands/to_tsv.rs b/src/commands/to_tsv.rs index 2842db2315..a0cbf1c1bd 100644 --- a/src/commands/to_tsv.rs +++ b/src/commands/to_tsv.rs @@ -37,6 +37,9 @@ pub fn value_to_tsv_value(v: &Value) -> Value { Value::Primitive(Primitive::String(s)) => Value::Primitive(Primitive::String(s.clone())), Value::Primitive(Primitive::Nothing) => Value::Primitive(Primitive::Nothing), Value::Primitive(Primitive::Boolean(b)) => Value::Primitive(Primitive::Boolean(b.clone())), + Value::Primitive(Primitive::Decimal(f)) => Value::Primitive(Primitive::Decimal(f.clone())), + Value::Primitive(Primitive::Int(i)) => Value::Primitive(Primitive::Int(i.clone())), + Value::Primitive(Primitive::Path(x)) => Value::Primitive(Primitive::Path(x.clone())), Value::Primitive(Primitive::Bytes(b)) => Value::Primitive(Primitive::Bytes(b.clone())), Value::Primitive(Primitive::Date(d)) => Value::Primitive(Primitive::Date(d.clone())), Value::Row(o) => Value::Row(o.clone()), @@ -51,10 +54,13 @@ fn to_string_helper(v: &Value) -> Result { Value::Primitive(Primitive::Date(d)) => Ok(d.to_string()), Value::Primitive(Primitive::Bytes(b)) => Ok(format!("{}", b)), Value::Primitive(Primitive::Boolean(_)) => Ok(v.as_string()?), + Value::Primitive(Primitive::Decimal(_)) => Ok(v.as_string()?), + Value::Primitive(Primitive::Int(_)) => Ok(v.as_string()?), + Value::Primitive(Primitive::Path(_)) => Ok(v.as_string()?), Value::Table(_) => return Ok(String::from("[table]")), Value::Row(_) => return Ok(String::from("[row]")), Value::Primitive(Primitive::String(s)) => return Ok(s.to_string()), - _ => Err(ShellError::string("Unexpected value")), + _ => return Err(ShellError::string("Unexpected value")), } } diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index c321e8115c..a6b8df8990 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -435,7 +435,7 @@ pub fn view_contents_interactive( let cursor = cursor(); let _ = cursor.show(); - let screen = RawScreen::disable_raw_mode(); + let _screen = RawScreen::disable_raw_mode(); Ok(()) } diff --git a/tests/commands_test.rs b/tests/commands_test.rs index 4e66aa7ab3..5188aee0aa 100644 --- a/tests/commands_test.rs +++ b/tests/commands_test.rs @@ -63,7 +63,7 @@ fn save_can_write_out_csv() { ); let actual = h::file_contents(expected_file); - assert!(actual.contains("[list list],A shell for the GitHub era,2018,ISC,nu,0.2.0")); + assert!(actual.contains("[Table],A shell for the GitHub era,2018,ISC,nu,0.2.0")); }) }