From 45a7c2e37eff37f81ed22d9dde7553624d93204c Mon Sep 17 00:00:00 2001 From: nibon7 Date: Mon, 11 Sep 2023 17:40:59 +0800 Subject: [PATCH] feat(nu): Make the completion scripts more general The generated scripts can be used as script, module and overlay. * script `source completion_script.nu` * module `use completion_script.nu *` * overlay `overlay use completion_script.nu` --- clap_complete_nushell/src/lib.rs | 2 +- clap_complete_nushell/tests/snapshots/aliases.nu | 2 +- clap_complete_nushell/tests/snapshots/basic.nu | 2 +- clap_complete_nushell/tests/snapshots/feature_sample.nu | 2 +- .../snapshots/home/test/nu/.config/nushell/completions/test.nu | 2 +- clap_complete_nushell/tests/snapshots/quoting.nu | 2 +- clap_complete_nushell/tests/snapshots/special_commands.nu | 2 +- clap_complete_nushell/tests/snapshots/sub_subcommands.nu | 2 +- clap_complete_nushell/tests/snapshots/value_hint.nu | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clap_complete_nushell/src/lib.rs b/clap_complete_nushell/src/lib.rs index 3ec128878be..e686b7cf584 100644 --- a/clap_complete_nushell/src/lib.rs +++ b/clap_complete_nushell/src/lib.rs @@ -42,7 +42,7 @@ impl Generator for Nushell { } completions.push_str("}\n\n"); - completions.push_str("use completions *\n"); + completions.push_str("export use completions *\n"); buf.write_all(completions.as_bytes()) .expect("Failed to write to generated file") diff --git a/clap_complete_nushell/tests/snapshots/aliases.nu b/clap_complete_nushell/tests/snapshots/aliases.nu index 2c84770d329..8263e60315e 100644 --- a/clap_complete_nushell/tests/snapshots/aliases.nu +++ b/clap_complete_nushell/tests/snapshots/aliases.nu @@ -15,4 +15,4 @@ module completions { } -use completions * +export use completions * diff --git a/clap_complete_nushell/tests/snapshots/basic.nu b/clap_complete_nushell/tests/snapshots/basic.nu index b905e5aa591..f1d52b1fe7c 100644 --- a/clap_complete_nushell/tests/snapshots/basic.nu +++ b/clap_complete_nushell/tests/snapshots/basic.nu @@ -27,4 +27,4 @@ module completions { } -use completions * +export use completions * diff --git a/clap_complete_nushell/tests/snapshots/feature_sample.nu b/clap_complete_nushell/tests/snapshots/feature_sample.nu index 1676a10d26d..f98c5a2bb52 100644 --- a/clap_complete_nushell/tests/snapshots/feature_sample.nu +++ b/clap_complete_nushell/tests/snapshots/feature_sample.nu @@ -36,4 +36,4 @@ module completions { } -use completions * +export use completions * diff --git a/clap_complete_nushell/tests/snapshots/home/test/nu/.config/nushell/completions/test.nu b/clap_complete_nushell/tests/snapshots/home/test/nu/.config/nushell/completions/test.nu index b8e0d6d402b..03c5cd6bd1b 100644 --- a/clap_complete_nushell/tests/snapshots/home/test/nu/.config/nushell/completions/test.nu +++ b/clap_complete_nushell/tests/snapshots/home/test/nu/.config/nushell/completions/test.nu @@ -255,4 +255,4 @@ module completions { } -use completions * +export use completions * diff --git a/clap_complete_nushell/tests/snapshots/quoting.nu b/clap_complete_nushell/tests/snapshots/quoting.nu index 3c5e6ccc5a5..485d77d4cec 100644 --- a/clap_complete_nushell/tests/snapshots/quoting.nu +++ b/clap_complete_nushell/tests/snapshots/quoting.nu @@ -75,4 +75,4 @@ module completions { } -use completions * +export use completions * diff --git a/clap_complete_nushell/tests/snapshots/special_commands.nu b/clap_complete_nushell/tests/snapshots/special_commands.nu index 3111f51cdc3..fc01a39acba 100644 --- a/clap_complete_nushell/tests/snapshots/special_commands.nu +++ b/clap_complete_nushell/tests/snapshots/special_commands.nu @@ -64,4 +64,4 @@ module completions { } -use completions * +export use completions * diff --git a/clap_complete_nushell/tests/snapshots/sub_subcommands.nu b/clap_complete_nushell/tests/snapshots/sub_subcommands.nu index 607a9296dbd..c6e32a0b048 100644 --- a/clap_complete_nushell/tests/snapshots/sub_subcommands.nu +++ b/clap_complete_nushell/tests/snapshots/sub_subcommands.nu @@ -73,4 +73,4 @@ module completions { } -use completions * +export use completions * diff --git a/clap_complete_nushell/tests/snapshots/value_hint.nu b/clap_complete_nushell/tests/snapshots/value_hint.nu index 82a91ae80c6..2cc0b5ab800 100644 --- a/clap_complete_nushell/tests/snapshots/value_hint.nu +++ b/clap_complete_nushell/tests/snapshots/value_hint.nu @@ -24,4 +24,4 @@ module completions { } -use completions * +export use completions *