From bb06661d2451d90d6fea8575f5faa8bd1d9c4b53 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Wed, 6 Sep 2023 19:26:53 +0200 Subject: [PATCH] Document that `open` looks up `from` subcommands (#10255) # Description Related to https://github.com/nushell/nushell.github.io/pull/1048 Include this information in the command help. # User-Facing Changes As soon as this information is documented people are much more likely to depend on it so we need to be careful in the future if this design sparks joy or not. --- crates/nu-command/src/filesystem/open.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/nu-command/src/filesystem/open.rs b/crates/nu-command/src/filesystem/open.rs index 4ff8fca58..94ac2ff9a 100644 --- a/crates/nu-command/src/filesystem/open.rs +++ b/crates/nu-command/src/filesystem/open.rs @@ -30,6 +30,10 @@ impl Command for Open { "Load a file into a cell, converting to table if possible (avoid by appending '--raw')." } + fn extra_usage(&self) -> &str { + "Support to automatically parse files with an extension `.xyz` can be provided by a `from xyz` command in scope." + } + fn search_terms(&self) -> Vec<&str> { vec!["load", "read", "load_file", "read_file"] } @@ -241,6 +245,11 @@ impl Command for Open { example: "open myfile.txt --raw | decode utf-8", result: None, }, + Example { + description: "Create a custom `from` parser to open newline-delimited JSON files with `open`", + example: r#"def "from ndjson" [] { from json -o }; open myfile.ndjson"#, + result: None, + }, ] } }