mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:45:56 +02:00
Filesystem commands print --verbose to stderr (#8014)
# Description Makes `mkdir`, `cp`, `mv` and `rm` return nothing and print info to stderr:  See https://github.com/nushell/nushell/pull/7925#issuecomment-1420861638 and [discord](https://discord.com/channels/601130461678272522/615329862395101194/1072523941865857055). # User-Facing Changes `mkdir`, `cp`, `mv` and `rm` will return nothing and print info to stderr with `--verbose` flag. # 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:
@ -644,6 +644,33 @@ impl PipelineData {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
/// Consume and print self data immediately.
|
||||
///
|
||||
/// Unlike [print] does not call `table` to format data and just prints it
|
||||
/// one element on a line
|
||||
/// * `no_newline` controls if we need to attach newline character to output.
|
||||
/// * `to_stderr` controls if data is output to stderr, when the value is false, the data is output to stdout.
|
||||
pub fn print_not_formatted(
|
||||
self,
|
||||
engine_state: &EngineState,
|
||||
no_newline: bool,
|
||||
to_stderr: bool,
|
||||
) -> Result<i64, ShellError> {
|
||||
let config = engine_state.get_config();
|
||||
|
||||
if let PipelineData::ExternalStream {
|
||||
stdout: stream,
|
||||
stderr: stderr_stream,
|
||||
exit_code,
|
||||
..
|
||||
} = self
|
||||
{
|
||||
print_if_stream(stream, stderr_stream, to_stderr, exit_code)
|
||||
} else {
|
||||
self.write_all_and_flush(engine_state, config, no_newline, to_stderr)
|
||||
}
|
||||
}
|
||||
|
||||
fn write_all_and_flush(
|
||||
self,
|
||||
engine_state: &EngineState,
|
||||
|
Reference in New Issue
Block a user