Stdout/Stderr redirection (#7185)

This adds new pipeline connectors called out> and err> which redirect either stdout or stderr to a file. You can also use out+err> (or err+out>) to redirect both streams into a file.
This commit is contained in:
JT
2022-11-23 07:26:13 +13:00
committed by GitHub
parent c9f9078726
commit 74a73f9838
15 changed files with 856 additions and 346 deletions

View File

@ -134,10 +134,10 @@ impl NuCompleter {
for pipeline in output.pipelines.into_iter() {
for pipeline_element in pipeline.elements {
match pipeline_element {
PipelineElement::Expression(expr)
| PipelineElement::Redirect(expr)
| PipelineElement::And(expr)
| PipelineElement::Or(expr) => {
PipelineElement::Expression(_, expr)
| PipelineElement::Redirection(_, _, expr)
| PipelineElement::And(_, expr)
| PipelineElement::Or(_, expr) => {
let flattened: Vec<_> = flatten_expression(&working_set, &expr);
let span_offset: usize = alias_offset.iter().sum();
let mut spans: Vec<String> = vec![];

View File

@ -120,6 +120,10 @@ impl Highlighter for NuHighlighter {
FlatShape::GlobPattern => add_colored_token!(shape.1, next_token),
FlatShape::Variable => add_colored_token!(shape.1, next_token),
FlatShape::Flag => add_colored_token!(shape.1, next_token),
FlatShape::Pipe => add_colored_token!(shape.1, next_token),
FlatShape::And => add_colored_token!(shape.1, next_token),
FlatShape::Or => add_colored_token!(shape.1, next_token),
FlatShape::Redirection => add_colored_token!(shape.1, next_token),
FlatShape::Custom(..) => add_colored_token!(shape.1, next_token),
}
last_seen_span = shape.0.end;
@ -232,10 +236,10 @@ fn find_matching_block_end_in_block(
for p in &block.pipelines {
for e in &p.elements {
match e {
PipelineElement::Expression(e)
| PipelineElement::Redirect(e)
| PipelineElement::And(e)
| PipelineElement::Or(e) => {
PipelineElement::Expression(_, e)
| PipelineElement::Redirection(_, _, e)
| PipelineElement::And(_, e)
| PipelineElement::Or(_, e) => {
if e.span.contains(global_cursor_offset) {
if let Some(pos) = find_matching_block_end_in_expr(
line,