limit the ide-check error amount (#8875)

# Description

This PR limits the amount of errors returned with the --ide-check flag.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
This commit is contained in:
Darren Schroeder
2023-04-13 12:53:18 -05:00
committed by GitHub
parent 3603610026
commit a33a7960bb
4 changed files with 27 additions and 16 deletions

View File

@ -37,9 +37,8 @@ pub(crate) fn gather_commandline_args() -> (Vec<String>, String, Vec<String>) {
#[cfg(feature = "plugin")]
"--plugin-config" => args.next().map(|a| escape_quote_string(&a)),
"--log-level" | "--log-target" | "--testbin" | "--threads" | "-t"
| "--include-path" | "-I" | "--ide-goto-def" | "--ide-hover" | "--ide-complete" => {
args.next()
}
| "--include-path" | "-I" | "--ide-goto-def" | "--ide-hover" | "--ide-complete"
| "--ide-check" => args.next(),
_ => None,
};
@ -92,12 +91,6 @@ pub(crate) fn parse_commandline_args(
)) = pipeline.elements.get(0)
{
let redirect_stdin = call.get_named_arg("stdin");
let ide_goto_def: Option<Value> =
call.get_flag(engine_state, &mut stack, "ide-goto-def")?;
let ide_hover: Option<Value> = call.get_flag(engine_state, &mut stack, "ide-hover")?;
let ide_complete: Option<Value> =
call.get_flag(engine_state, &mut stack, "ide-complete")?;
let ide_check = call.get_named_arg("ide-check");
let login_shell = call.get_named_arg("login");
let interactive_shell = call.get_named_arg("interactive");
let commands: Option<Expression> = call.get_flag_expr("commands");
@ -115,6 +108,13 @@ pub(crate) fn parse_commandline_args(
let table_mode: Option<Value> =
call.get_flag(engine_state, &mut stack, "table-mode")?;
let ide_goto_def: Option<Value> =
call.get_flag(engine_state, &mut stack, "ide-goto-def")?;
let ide_hover: Option<Value> = call.get_flag(engine_state, &mut stack, "ide-hover")?;
let ide_complete: Option<Value> =
call.get_flag(engine_state, &mut stack, "ide-complete")?;
let ide_check: Option<Value> = call.get_flag(engine_state, &mut stack, "ide-check")?;
fn extract_contents(
expression: Option<Expression>,
) -> Result<Option<Spanned<String>>, ShellError> {
@ -229,7 +229,7 @@ pub(crate) struct NushellCliArgs {
pub(crate) ide_goto_def: Option<Value>,
pub(crate) ide_hover: Option<Value>,
pub(crate) ide_complete: Option<Value>,
pub(crate) ide_check: Option<Spanned<String>>,
pub(crate) ide_check: Option<Value>,
}
#[derive(Clone)]
@ -312,8 +312,9 @@ impl Command for Nu {
"list completions for the item at the given position",
None,
)
.switch(
.named(
"ide-check",
SyntaxShape::Int,
"run a diagnostic check on the given source",
None,
);