Skip to content

Commit

Permalink
fix the signature of input list (#9977)
Browse files Browse the repository at this point in the history
# Description
in its documentation, `input list` says it only accepts the following
signatures
- `list<any> -> list<any>`
- `list<string> -> string`

however this is incorrect as the following is allowed and even in the
help page
```nushell
[1 2 3] | input list  # -> returns an `int`
```

this PR fixes the signature of `input list`.
- with no option or `--fuzzy`, `input list` takes a `list<any>` and
outputs a single `any`
- with `--multi`, `input list` takes a `list<any>` and outputs a
`list<any>`

# User-Facing Changes
the input output signature of `input list` is now
```
  ╭───┬───────────┬───────────╮
  │ # │   input   │  output   │
  ├───┼───────────┼───────────┤
  │ 0 │ list<any> │ list<any> │
  │ 1 │ list<any> │ any       │
  ╰───┴───────────┴───────────╯
```
# Tests + Formatting
this shouldn't change anything as `[1 2 3] | input list` already works.

# After Submitting
  • Loading branch information
amtoine committed Aug 10, 2023
1 parent f9ffd9a commit 23170ff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/nu-command/src/platform/input/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Command for InputList {
Type::List(Box::new(Type::Any)),
Type::List(Box::new(Type::Any)),
),
(Type::List(Box::new(Type::String)), Type::String),
(Type::List(Box::new(Type::Any)), Type::Any),
])
.optional("prompt", SyntaxShape::String, "the prompt to display")
.switch(
Expand Down

0 comments on commit 23170ff

Please sign in to comment.