1
0
mirror of https://github.com/nushell/nushell.git synced 2025-04-24 13:18:18 +02:00
nushell/crates
Piepmatz aaf973bbba
Add Stack::stdout_file and Stack::stderr_file to capture stdout/-err of external commands ()
# Description
In this PR I added two new methods to `Stack`, `stdout_file` and
`stderr_file`. These two modify the inner `StackOutDest` and set a
`File` into the `stdout` and `stderr` respectively. Different to the
`push_redirection` methods, these do not require to hold a guard up all
the time but require ownership of the stack.

This is primarly useful for applications that use `nu` as a language but
not the `nushell`.

This PR replaces my first attempt  to add a way to capture
stdout/-err of external commands. Capturing the stdout without having to
write into a file is possible with crates like
[`os_pipe`](https://docs.rs/os_pipe), an example for this is given in
the doc comment of the `stdout_file` command and can be executed as a
doctest (although it doesn't validate that you actually got any data).

This implementation takes `File` as input to make it easier to implement
on different operating systems without having to worry about
`OwnedHandle` or `OwnedFd`. Also this doesn't expose any use `os_pipe`
to not leak its types into this API, making it depend on it.

As in my previous attempt, @IanManske guided me here.

# User-Facing Changes
This change has no effect on `nushell` and therefore no user-facing
changes.

# Tests + Formatting
This only exposes a new way of using already existing code and has
therefore no further testing. The doctest succeeds on my machine at
least (x86 Windows, 64 Bit).

# After Submitting
All the required documentation is already part of this PR.
2024-05-13 18:48:38 +00:00
..
nu_plugin_custom_values Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu_plugin_example feat: add an echo command to nu_plugin_example () 2024-05-08 12:45:44 -07:00
nu_plugin_formats Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu_plugin_gstat Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu_plugin_inc Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu_plugin_nu_example Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu_plugin_polars Polars lazy refactor () 2024-05-06 23:19:11 +00:00
nu_plugin_python Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu_plugin_query Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu_plugin_stress_internals Upgrade to interprocess 2.0.0 () 2024-05-02 22:31:33 -07:00
nu-cli Implement PWD recovery () 2024-05-10 11:06:33 -05:00
nu-cmd-base Implement PWD recovery () 2024-05-10 11:06:33 -05:00
nu-cmd-dataframe Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu-cmd-extra ListStream touchup () 2024-05-05 16:00:59 +00:00
nu-cmd-lang Shrink Value by boxing Range/Closure () 2024-05-09 08:10:58 +08:00
nu-cmd-plugin Make the message when running a plugin exe directly clearer () 2024-05-07 20:12:32 -07:00
nu-color-config Shrink Value by boxing Range/Closure () 2024-05-09 08:10:58 +08:00
nu-command Add example and search term for 'repeat' to the fill command () 2024-05-12 20:55:07 -05:00
nu-engine Fix pipe redirection into complete () 2024-05-11 15:32:00 +00:00
nu-explore Add sys subcommands () 2024-05-06 23:20:27 +00:00
nu-glob Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu-json Minimize future false positive typos () 2024-05-04 15:00:44 +00:00
nu-lsp Refactor the CLI code a bit () 2024-05-10 07:29:27 +08:00
nu-parser Fix raw strings as external argument () 2024-05-10 07:50:31 +08:00
nu-path Fix trailing slash in PWD set by cd () 2024-05-04 12:38:37 +03:00
nu-plugin Make the message when running a plugin exe directly clearer () 2024-05-07 20:12:32 -07:00
nu-plugin-core ListStream touchup () 2024-05-05 16:00:59 +00:00
nu-plugin-engine Shrink Value by boxing Range/Closure () 2024-05-09 08:10:58 +08:00
nu-plugin-protocol ListStream touchup () 2024-05-05 16:00:59 +00:00
nu-plugin-test-support ListStream touchup () 2024-05-05 16:00:59 +00:00
nu-pretty-hex Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu-protocol Add Stack::stdout_file and Stack::stderr_file to capture stdout/-err of external commands () 2024-05-13 18:48:38 +00:00
nu-std Update PR template () 2024-05-13 08:45:44 -05:00
nu-system Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu-table Avoid taking unnecessary ownership of intermediates () 2024-05-04 00:53:15 +00:00
nu-term-grid Bump version to 0.93.1 () 2024-05-01 17:19:20 -05:00
nu-test-support Avoid taking unnecessary ownership of intermediates () 2024-05-04 00:53:15 +00:00
nu-utils overhaul shell_integration to enable individual control over ansi escape sequences () 2024-05-02 09:56:50 -04:00
nuon Shrink Value by boxing Range/Closure () 2024-05-09 08:10:58 +08:00
README.md Correct spelling () 2021-11-25 11:11:20 -06:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.