From f1ce0c98fd56d2b87859995b09ea707ca0b9fb1c Mon Sep 17 00:00:00 2001 From: Piepmatz Date: Wed, 25 Dec 2024 13:14:04 +0100 Subject: [PATCH] Add content type metadata to `config nu` commands (#14666) # Description In v0.101.0 we got `config nu --default` and `config nu --doc` which return a default config. That default config is valid `.nu`, so it should have the metadata for it. We defined our MIME types [here in the docs](https://www.nushell.sh/lang-guide/chapters/mime_types.html), so I added that. # User-Facing Changes Tools that read the metadata can now also detect that these two commands are nushell scripts. # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :green_circle: `toolkit test` - :green_circle: `toolkit test stdlib` # After Submitting --- crates/nu-command/src/env/config/config_nu.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/nu-command/src/env/config/config_nu.rs b/crates/nu-command/src/env/config/config_nu.rs index 5295fe5247..ee09965aa6 100644 --- a/crates/nu-command/src/env/config/config_nu.rs +++ b/crates/nu-command/src/env/config/config_nu.rs @@ -1,4 +1,5 @@ use nu_engine::command_prelude::*; +use nu_protocol::PipelineMetadata; #[derive(Clone)] pub struct ConfigNu; @@ -70,13 +71,21 @@ impl Command for ConfigNu { // `--default` flag handling if default_flag { let head = call.head; - return Ok(Value::string(nu_utils::get_default_config(), head).into_pipeline_data()); + return Ok(Value::string(nu_utils::get_default_config(), head) + .into_pipeline_data_with_metadata( + PipelineMetadata::default() + .with_content_type("application/x-nuscript".to_string().into()), + )); } // `--doc` flag handling if doc_flag { let head = call.head; - return Ok(Value::string(nu_utils::get_doc_config(), head).into_pipeline_data()); + return Ok(Value::string(nu_utils::get_doc_config(), head) + .into_pipeline_data_with_metadata( + PipelineMetadata::default() + .with_content_type("application/x-nuscript".to_string().into()), + )); } super::config_::start_editor("config-path", engine_state, stack, call)