mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 04:45:04 +02:00
Rename IoStream
to OutDest
(#12433)
# Description I spent a while trying to come up with a good name for what is currently `IoStream`. Looking back, this name is not the best, because it: 1. Implies that it is a stream, when it all it really does is specify the output destination for a stream/pipeline. 2. Implies that it handles input and output, when it really only handles output. So, this PR renames `IoStream` to `OutDest` instead, which should be more clear.
This commit is contained in:
6
crates/nu-command/src/env/config/utils.rs
vendored
6
crates/nu-command/src/env/config/utils.rs
vendored
@ -1,5 +1,5 @@
|
||||
use crate::ExternalCommand;
|
||||
use nu_protocol::{IoStream, Span, Spanned};
|
||||
use nu_protocol::{OutDest, Span, Spanned};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
pub(crate) fn gen_command(
|
||||
@ -29,8 +29,8 @@ pub(crate) fn gen_command(
|
||||
name,
|
||||
args,
|
||||
arg_keep_raw: vec![false; number_of_args],
|
||||
out: IoStream::Inherit,
|
||||
err: IoStream::Inherit,
|
||||
out: OutDest::Inherit,
|
||||
err: OutDest::Inherit,
|
||||
env_vars: env_vars_str,
|
||||
}
|
||||
}
|
||||
|
2
crates/nu-command/src/env/with_env.rs
vendored
2
crates/nu-command/src/env/with_env.rs
vendored
@ -79,7 +79,7 @@ fn with_env(
|
||||
|
||||
let capture_block: Closure = call.req(engine_state, stack, 1)?;
|
||||
let block = engine_state.get_block(capture_block.block_id);
|
||||
let mut stack = stack.captures_to_stack_preserve_stdio(capture_block.captures);
|
||||
let mut stack = stack.captures_to_stack_preserve_out_dest(capture_block.captures);
|
||||
|
||||
let mut env: HashMap<String, Value> = HashMap::new();
|
||||
|
||||
|
@ -3,7 +3,7 @@ use nu_engine::{command_prelude::*, current_dir};
|
||||
use nu_path::expand_path_with;
|
||||
use nu_protocol::{
|
||||
ast::{Expr, Expression},
|
||||
DataSource, IoStream, PipelineMetadata, RawStream,
|
||||
DataSource, OutDest, PipelineMetadata, RawStream,
|
||||
};
|
||||
use std::{
|
||||
fs::File,
|
||||
@ -261,8 +261,8 @@ impl Command for Save {
|
||||
]
|
||||
}
|
||||
|
||||
fn stdio_redirect(&self) -> (Option<IoStream>, Option<IoStream>) {
|
||||
(Some(IoStream::Capture), Some(IoStream::Capture))
|
||||
fn pipe_redirection(&self) -> (Option<OutDest>, Option<OutDest>) {
|
||||
(Some(OutDest::Capture), Some(OutDest::Capture))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use nu_engine::{command_prelude::*, get_eval_block_with_early_return};
|
||||
use nu_protocol::{engine::Closure, IoStream, RawStream};
|
||||
use nu_protocol::{engine::Closure, OutDest, RawStream};
|
||||
use std::{sync::mpsc, thread};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -73,7 +73,7 @@ use it in your pipeline."#
|
||||
|
||||
let closure_engine_state = engine_state.clone();
|
||||
let mut closure_stack = stack
|
||||
.captures_to_stack_preserve_stdio(captures)
|
||||
.captures_to_stack_preserve_out_dest(captures)
|
||||
.reset_pipes();
|
||||
|
||||
let metadata = input.metadata();
|
||||
@ -198,8 +198,8 @@ use it in your pipeline."#
|
||||
}
|
||||
}
|
||||
|
||||
fn stdio_redirect(&self) -> (Option<IoStream>, Option<IoStream>) {
|
||||
(Some(IoStream::Capture), Some(IoStream::Capture))
|
||||
fn pipe_redirection(&self) -> (Option<OutDest>, Option<OutDest>) {
|
||||
(Some(OutDest::Capture), Some(OutDest::Capture))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
use nu_protocol::IoStream;
|
||||
use nu_protocol::OutDest;
|
||||
use std::thread;
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -118,7 +118,7 @@ impl Command for Complete {
|
||||
}]
|
||||
}
|
||||
|
||||
fn stdio_redirect(&self) -> (Option<IoStream>, Option<IoStream>) {
|
||||
(Some(IoStream::Capture), Some(IoStream::Capture))
|
||||
fn pipe_redirection(&self) -> (Option<OutDest>, Option<OutDest>) {
|
||||
(Some(OutDest::Capture), Some(OutDest::Capture))
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::run_external::create_external_command;
|
||||
use nu_engine::{command_prelude::*, current_dir};
|
||||
use nu_protocol::IoStream;
|
||||
use nu_protocol::OutDest;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Exec;
|
||||
@ -59,8 +59,8 @@ fn exec(
|
||||
call: &Call,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let mut external_command = create_external_command(engine_state, stack, call)?;
|
||||
external_command.out = IoStream::Inherit;
|
||||
external_command.err = IoStream::Inherit;
|
||||
external_command.out = OutDest::Inherit;
|
||||
external_command.err = OutDest::Inherit;
|
||||
|
||||
let cwd = current_dir(engine_state, stack)?;
|
||||
let mut command = external_command.spawn_simple_command(&cwd.to_string_lossy())?;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_cmd_base::hook::eval_hook;
|
||||
use nu_engine::{command_prelude::*, env_to_strings, get_eval_expression};
|
||||
use nu_protocol::{ast::Expr, did_you_mean, IoStream, ListStream, NuGlob, RawStream};
|
||||
use nu_protocol::{ast::Expr, did_you_mean, ListStream, NuGlob, OutDest, RawStream};
|
||||
use nu_system::ForegroundChild;
|
||||
use nu_utils::IgnoreCaseExt;
|
||||
use os_pipe::PipeReader;
|
||||
@ -225,8 +225,8 @@ pub struct ExternalCommand {
|
||||
pub name: Spanned<String>,
|
||||
pub args: Vec<Spanned<String>>,
|
||||
pub arg_keep_raw: Vec<bool>,
|
||||
pub out: IoStream,
|
||||
pub err: IoStream,
|
||||
pub out: OutDest,
|
||||
pub err: OutDest,
|
||||
pub env_vars: HashMap<String, String>,
|
||||
}
|
||||
|
||||
@ -523,7 +523,7 @@ impl ExternalCommand {
|
||||
RawStream::new(Box::new(ByteLines::new(err)), ctrlc.clone(), head, None)
|
||||
});
|
||||
|
||||
if matches!(self.err, IoStream::Pipe) {
|
||||
if matches!(self.err, OutDest::Pipe) {
|
||||
(stderr, stdout)
|
||||
} else {
|
||||
(stdout, stderr)
|
||||
@ -634,7 +634,7 @@ impl ExternalCommand {
|
||||
|
||||
// If the external is not the last command, its output will get piped
|
||||
// either as a string or binary
|
||||
let reader = if matches!(self.out, IoStream::Pipe) && matches!(self.err, IoStream::Pipe) {
|
||||
let reader = if matches!(self.out, OutDest::Pipe) && matches!(self.err, OutDest::Pipe) {
|
||||
let (reader, writer) = os_pipe::pipe()?;
|
||||
let writer_clone = writer.try_clone()?;
|
||||
process.stdout(writer);
|
||||
|
Reference in New Issue
Block a user