nushell/src/tests
WindSoilder d2c87ad4b4
differentiating between --x and --x: bool (#10456)
# Description
Fixes: #10450 

This pr differentiating between `--x: bool` and `--x`

Here are examples which demostrate difference between them:
```nushell
def a [--x: bool] { $x };
a --x    # not allowed, you need to parse a value to the flag.
a        # it's allowed, and the value of `$x` is false, which behaves the same to `def a [--x] { $x }; a`
```

For boolean flag with default value, it works a little bit different to
#10450 mentioned:
```nushell
def foo [--option: bool = false] { $option }
foo                  # output false
foo --option         # not allowed, you need to parse a value to the flag.
foo --option true    # output true
```

# User-Facing Changes
After the pr, the following code is not allowed:
```nushell
def a [--x: bool] { $x }; a --x
```

Instead, you have to pass a value to flag `--x` like `a --x false`. But
bare flag works in the same way as before.

## Update: one more breaking change to help on #7260 
```
def foo [--option: bool] { $option == null }
foo
```
After the pr, if we don't use a boolean flag, the value will be `null`
instead of `true`. Because here `--option: bool` is treated as a flag
rather than a switch

---------

Co-authored-by: amtoine <stevan.antoine@gmail.com>
2023-09-23 10:20:48 +02:00
..
test_bits.rs Input output checking (#9680) 2023-07-14 15:20:35 +12:00
test_cell_path.rs rename the types with spaces in them to use - (#9929) 2023-09-06 13:22:12 -05:00
test_commandline.rs fix: fix cursor position when cursor is at the end of the commandline (#9030) 2023-04-28 07:02:45 -05:00
test_conditionals.rs Add OneOf shape to fix else (#7385) 2022-12-08 08:58:54 +13:00
test_config_path.rs Clippy in tests (#10394) 2023-09-16 21:49:10 +02:00
test_config.rs Add config mutation tests (#7437) 2022-12-12 12:46:25 -06:00
test_converters.rs Fix to json escape logic (#4478) 2022-02-15 06:55:57 -05:00
test_custom_commands.rs differentiating between --x and --x: bool (#10456) 2023-09-23 10:20:48 +02:00
test_engine.rs Allow parse-time evaluation of calls, pipelines and subexpressions (#9499) 2023-08-26 16:41:29 +03:00
test_env.rs Remove the 'env' command, as we have the variable (#8185) 2023-03-01 21:20:00 +13:00
test_help.rs Change str replace to match substring by default (#10038) 2023-08-18 00:18:16 +03:00
test_hiding.rs remove let-env, focus on mutating $env (#9574) 2023-07-01 07:57:51 +12:00
test_ide.rs limit the ide-check error amount (#8875) 2023-04-13 12:53:18 -05:00
test_iteration.rs Remove deprecated --numbered flag from four commands (#7777) 2023-02-02 16:59:58 -06:00
test_known_external.rs Allow exporting extern-wrapped (#10025) 2023-08-18 20:45:33 +03:00
test_math.rs Change comparison operators to allow nulls (#8617) 2023-03-26 12:10:09 +13:00
test_modules.rs Module: support defining const and use const variables inside of function (#9773) 2023-08-01 07:09:52 +08:00
test_parser.rs differentiating between --x and --x: bool (#10456) 2023-09-23 10:20:48 +02:00
test_ranges.rs improve operation mismatch errors (#8800) 2023-04-08 09:32:44 +12:00
test_regex.rs improve operation mismatch errors (#8800) 2023-04-08 09:32:44 +12:00
test_signatures.rs allow tables to have annotations (#9613) 2023-07-07 11:06:09 +02:00
test_stdlib.rs split $nu variable into scope commands and simpler $nu (#9487) 2023-06-21 09:33:01 +12:00
test_strings.rs improve operation mismatch errors (#8800) 2023-04-08 09:32:44 +12:00
test_table_operations.rs remove --column from length command and remove record processing (#10091) 2023-08-23 16:03:26 -05:00
test_type_check.rs rename from date format to format date (#9902) 2023-08-04 06:06:00 +12:00