mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 01:39:46 +02:00
Add --no-newline option to nu
(#12410)
# Description I have `nu` set as my shell in my editor, which allows me to easily pipe selections of text to things like `str pascal-case` or even more complex string operation pipelines, which I find super handy. However, the only annoying thing is that I pretty much always have to add `| print -n` at the end, because `nu` adds a newline when it prints the resulting value. This adds a `--no-newline` option to stop that from happening, and then you don't need to pipe to `print -n` anymore, you can just have your shell command for your editor contain that flag. # User-Facing Changes - Add `--no-newline` command line option # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib`
This commit is contained in:
@@ -273,6 +273,17 @@ fn run_in_noninteractive_mode() {
|
||||
assert!(child_output.stderr.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_with_no_newline() {
|
||||
let child_output = std::process::Command::new(nu_test_support::fs::executable_path())
|
||||
.args(["--no-newline", "-c", "\"hello world\""])
|
||||
.output()
|
||||
.expect("failed to run nu");
|
||||
|
||||
assert_eq!("hello world", String::from_utf8_lossy(&child_output.stdout)); // with no newline
|
||||
assert!(child_output.stderr.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn main_script_can_have_subcommands1() {
|
||||
Playground::setup("main_subcommands", |dirs, sandbox| {
|
||||
|
Reference in New Issue
Block a user