nushell/crates/nu-command/tests/format_conversions
João Fidalgo 63335e99ae
Fix usage of --tabs flag while converting to json (#12115) (#12251)
closes #12115 

# Description
This fix addresses a bug where the --tabs flag couldn't be utilized due
to improper handling of the tab quantity provided by the user.
Previously, the code mistakenly attempted to convert the tab quantity to
a boolean value, leading to a conversion error. The resolution involves
adjusting the condition clauses to properly validate the presence of the
flag's value. Now, the code checks whether the get_flag() function
returns a value or None associated with the --tabs flag. This adjustment
enables the --tabs flag to function correctly, triggering the
appropriate condition and allowing the conversion to proceed as
expected. Similarly, the fix applies to the --indent flag. Additionally,
a default case was added, and the conversion now works properly without
flags. Two tests were added to validate the corrected behavior of these
flags.

# User-Facing Changes
Now the conversion should work properly instead of displaying an error.

# Tests + Formatting
-🟢 toolkit fmt
-🟢 toolkit clippy
-🟢 toolkit test
-🟢 toolkit test stdlib

To run added tests:
- cargo test --package nu-command --test main --
format_conversions::json::test_tabs_indent_flag
- cargo test --package nu-command --test main --
format_conversions::json::test_indent_flag
2024-03-20 11:55:51 -05:00
..
csv.rs Fix ignored clippy lints (#12160) 2024-03-11 19:46:04 +01:00
html.rs Remove feat extra and include in default (#12140) 2024-03-10 17:29:02 +01:00
json.rs Fix usage of --tabs flag while converting to json (#12115) (#12251) 2024-03-20 11:55:51 -05:00
markdown.rs Clean up tests containing unnecessary cwd: tokens (#9692) 2023-07-17 18:43:51 +02:00
mod.rs Remove feat extra and include in default (#12140) 2024-03-10 17:29:02 +01:00
nuon.rs Disallow duplicated columns in table literals (#10875) 2023-11-01 21:25:35 +01:00
ods.rs Add long options for formats (#10645) 2023-10-08 19:07:09 +02:00
ssv.rs refactor: change column names from 'Column*' to 'column*' (#4556) 2022-02-19 19:26:47 -05:00
toml.rs Clean up tests containing unnecessary cwd: tokens (#9692) 2023-07-17 18:43:51 +02:00
tsv.rs Fix ignored clippy lints (#12160) 2024-03-11 19:46:04 +01:00
url.rs Rename to url command to url build-query (#7702) 2023-01-15 10:16:29 -08:00
xlsx.rs Add date support in from xlsx (#11952) 2024-02-24 07:25:51 -06:00
xml.rs Add self-closed tag support for to xml (#11577) 2024-01-19 05:35:29 -06:00
yaml.rs Clean up tests containing unnecessary cwd: tokens (#9692) 2023-07-17 18:43:51 +02:00