-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use span
in error make
#10914
Comments
I wonder if we can use both? like if we detect a "span:" key, look for a span and if we see a "start:" and "end:" use the individual ones. I say that we probably want to keep start/end because sometimes you have to tweak the span's start or end. That probably doesn't happen that often but it may happen. |
@fdncred in theory, there are two ways to ways to tweak the ends with this proposal: mut span = (metadata $x).span
span.end += 10
... error make {
label: {
span: {
start: 10
end: 20
}
}
} I didn't think about the idea to mix them, though, and I like it. One thing which I worry about is the error message when the two get mixed. If someone puts both |
It should be an error if someone puts both span and start/end stating that it's disallowed and to choose either span or start/end. One other benefit to doing it this way is that it keeps us from having a breaking-change. |
i think this would be quite cool to have 🙏 |
Related/Unrelated, I was reminded again today that Example ❯ ls | into list -adfa
Error: nu::parser::unknown_flag
× The `into list` command doesn't have flag `-a`.
╭─[entry #44:1:1]
1 │ ls | into list -adfa
· ┬
· ╰── unknown flag
╰────
help: Available flags: --help(-h). Use `--help` for more information. In fact, I'd love to be able to optionally support every functionality that nushell supports with miette-style errors. |
completely support you here @fdncred 👍 |
@amtoine I checked it out and it turns out the help option was added to |
@KAAtheWiseGit |
- Replaced `start`/`end` with span. - Fixed standard library. - Add `help` option. - Add a couple more errors for invalid record types. Resolve nushell#10914
- Replaced `start`/`end` with span. - Fixed standard library. - Add `help` option. - Add a couple more errors for invalid record types. Resolve nushell#10914
- Replaced `start`/`end` with span. - Fixed standard library. - Add `help` option. - Add a couple more errors for invalid record types. Resolve nushell#10914
- Replaced `start`/`end` with span. - Fixed standard library. - Add `help` option. - Add a couple more errors for invalid record types. Resolve #10914 # Description # User-Facing Changes - **BREAKING CHANGE:** `error make` now takes in `span` instead of `start`/`end`: ```Nushell error make { msg: "Message" label: { text: "Label text" span: (metadata $var).span } } ``` - `error make` now has a `help` argument for custom error help.
- Replaced `start`/`end` with span. - Fixed standard library. - Add `help` option. - Add a couple more errors for invalid record types. Resolve nushell#10914 # Description # User-Facing Changes - **BREAKING CHANGE:** `error make` now takes in `span` instead of `start`/`end`: ```Nushell error make { msg: "Message" label: { text: "Label text" span: (metadata $var).span } } ``` - `error make` now has a `help` argument for custom error help.
- Replaced `start`/`end` with span. - Fixed standard library. - Add `help` option. - Add a couple more errors for invalid record types. Resolve nushell#10914 # Description # User-Facing Changes - **BREAKING CHANGE:** `error make` now takes in `span` instead of `start`/`end`: ```Nushell error make { msg: "Message" label: { text: "Label text" span: (metadata $var).span } } ``` - `error make` now has a `help` argument for custom error help.
Related problem
Currently
error make
takes in a record, which hasstart
andend
fields. I think this is somewhat unergonomic, as in majority of times some existing span is passed to it. This would get rid of currently necessary patter of creating a temporaryspan
variable. And if a custom span has to be made (a rarer case, IMO), it can still be created manually, just with one more level of nesting.Describe the solution you'd like
Replace
label: {text: "...", start: ..., end: ...}
withlabel: {text: "...", span: ...}
.Example
Currently (an example from
error make
docs):With the proposed change:
The text was updated successfully, but these errors were encountered: