Repository navigation
feat: add --coerce for def - #18406
Skyrocket1653 wants to merge 4 commits into
Conversation
|
If we move forward with this (not sure we will) I probably wouldn't allow Also, I think |
def --wrapped example [...rest] { print ...$rest }
example --my-flag="hi"
--my-flag=hi
|
|
I have another idea |
|
What is your idea? |
|
There's a bug in the end-of-options code I think. I have this working right now in my PR. Does this satisfy your use case? ❯ def --wrapped example [--my-flag: string ...rest] {
let rest = $rest | skip 1 # skip the '--' delimiter
$rest | each { {type: ($in | describe) value: $in} } | print
print $"--my-flag='($my_flag)'"
}
❯ example --my-flag="hi" -- true false 001 --my-flag="goodbye"
╭─#─┬──type──┬───────value───────╮
│ 0 │ string │ true │
│ 1 │ string │ false │
│ 2 │ string │ 001 │
│ 3 │ string │ --my-flag=goodbye │
╰───┴────────┴───────────────────╯
--my-flag='hi' |
|
That does not work on my side. def --wrapped example [--my-flag: string ...rest] {
let rest = $rest | skip 1 # skip the '--' delimiter
$rest | each { {type: ($in | describe) value: $in} } | print
print $"--my-flag='($my_flag)'"
}
example --my-flag="hi" -- true false 001 --my-flag="goodbye"
┌───┬────────┬───────┐
│ # │ type │ value │
├───┼────────┼───────┤
│ 0 │ string │ true │
├───┼────────┼───────┤
│ 1 │ string │ false │
├───┼────────┼───────┤
│ 2 │ string │ 001 │
└───┴────────┴───────┘
--my-flag='goodbye'As you can see |
|
My flag |
|
I've also removed |
|
Oh wait I didn't see the pr you just made, I'm going to try it first. |
|
closed in favor of #18408 |
Description
Adds a
--coercewhich behavior is like--wrappedbut respects--.User-facing changes (Release notes)
Now this is possible:
Additional notes
Closes #18399