Use imported names in Command::run signatures (#7967)

# Description

_(Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.)_

I opened this PR to unify the run command method. It's mainly to improve
consistency across the tree.

# User-Facing Changes

None.

# 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

# 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:
Jérémy Audiger
2023-02-05 22:17:46 +01:00
committed by GitHub
parent a0e3ad2b70
commit 99076af18b
236 changed files with 469 additions and 409 deletions

View File

@ -31,7 +31,7 @@ impl Command for From {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(Value::String {
val: get_full_help(
&From.signature(),

View File

@ -49,7 +49,7 @@ impl Command for FromCsv {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
from_csv(engine_state, stack, call, input)
}

View File

@ -41,7 +41,7 @@ impl Command for FromEml {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let preview_body: Option<Spanned<i64>> =
call.get_flag(engine_state, stack, "preview-body")?;

View File

@ -34,7 +34,7 @@ impl Command for FromIcs {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
from_ics(input, head)
}

View File

@ -47,7 +47,7 @@ b=2' | from ini",
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
from_ini(input, head)
}

View File

@ -59,7 +59,7 @@ impl Command for FromJson {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let span = call.head;
let (string_input, span, metadata) = input.collect_string_strict(span)?;

View File

@ -57,7 +57,7 @@ impl Command for FromNuon {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let (string_input, _span, metadata) = input.collect_string_strict(head)?;

View File

@ -39,7 +39,7 @@ impl Command for FromOds {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let sel_sheets = if let Some(Value::List { vals: columns, .. }) =

View File

@ -60,7 +60,7 @@ impl Command for FromSsv {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
from_ssv(engine_state, stack, call, input)
}
}

View File

@ -58,7 +58,7 @@ b = [1, 2]' | from toml",
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let span = call.head;
let (mut string_input, span, metadata) = input.collect_string_strict(span)?;
string_input.push('\n');

View File

@ -43,7 +43,7 @@ impl Command for FromTsv {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
from_tsv(engine_state, stack, call, input)
}

View File

@ -26,7 +26,7 @@ impl Command for FromUrl {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
from_url(input, head)
}

View File

@ -32,7 +32,7 @@ impl Command for FromVcf {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
from_vcf(input, head)
}

View File

@ -39,7 +39,7 @@ impl Command for FromXlsx {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let sel_sheets = if let Some(Value::List { vals: columns, .. }) =

View File

@ -30,7 +30,7 @@ impl Command for FromXml {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
from_xml(input, head)
}

View File

@ -36,7 +36,7 @@ impl Command for FromYaml {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
from_yaml(input, head)
}
@ -66,7 +66,7 @@ impl Command for FromYml {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
from_yaml(input, head)
}

View File

@ -31,7 +31,7 @@ impl Command for To {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(Value::String {
val: get_full_help(
&To.signature(),

View File

@ -65,7 +65,7 @@ impl Command for ToCsv {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let noheaders = call.has_flag("noheaders");
let separator: Option<Spanned<String>> = call.get_flag(engine_state, stack, "separator")?;

View File

@ -157,7 +157,7 @@ impl Command for ToHtml {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
to_html(input, call, engine_state, stack)
}
}

View File

@ -43,7 +43,7 @@ impl Command for ToJson {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let raw = call.has_flag("raw");
let use_tabs = call.has_flag("tabs");

View File

@ -70,7 +70,7 @@ impl Command for ToMd {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let pretty = call.has_flag("pretty");
let per_element = call.has_flag("per-element");

View File

@ -33,7 +33,7 @@ impl Command for ToNuon {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(Value::String {
val: to_nuon(call, input)?,
span: call.head,

View File

@ -30,7 +30,7 @@ impl Command for ToText {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let span = call.head;
let config = engine_state.get_config();

View File

@ -36,7 +36,7 @@ impl Command for ToToml {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
to_toml(engine_state, input, head)
}

View File

@ -60,7 +60,7 @@ impl Command for ToXml {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let config = engine_state.get_config();
let pretty: Option<Spanned<i64>> = call.get_flag(engine_state, stack, "pretty")?;

View File

@ -36,7 +36,7 @@ impl Command for ToYaml {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
to_yaml(input, head)
}