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

@ -60,7 +60,7 @@ impl Command for Cd {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let path_val: Option<Spanned<String>> = call.opt(engine_state, stack, 0)?;
let cwd = current_dir(engine_state, stack)?;
let config = engine_state.get_config();

View File

@ -72,7 +72,7 @@ impl Command for Ls {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let all = call.has_flag("all");
let long = call.has_flag("long");
let short_names = call.has_flag("short-names");

View File

@ -62,7 +62,7 @@ impl Command for Mv {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
// TODO: handle invalid directory or insufficient permissions when moving
let spanned_source: Spanned<String> = call.req(engine_state, stack, 0)?;
let spanned_source = {

View File

@ -48,7 +48,7 @@ impl Command for Open {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let raw = call.has_flag("raw");
let call_span = call.head;
let ctrlc = engine_state.ctrlc.clone();

View File

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

View File

@ -35,7 +35,7 @@ impl Command for Start {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let path = call.opt::<Spanned<String>>(engine_state, stack, 0)?;
let path = {

View File

@ -66,7 +66,7 @@ impl Command for Watch {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let cwd = current_dir(engine_state, stack)?;
let path_arg: Spanned<String> = call.req(engine_state, stack, 0)?;