File tree Expand file tree Collapse file tree 1 file changed +7
-28
lines changed
clap_complete_nushell/src Expand file tree Collapse file tree 1 file changed +7
-28
lines changed Original file line number Diff line number Diff line change @@ -56,45 +56,24 @@ do {{
5656fn write_completion_script (
5757 var : & str ,
5858 name : & str ,
59- bin : & str ,
59+ _bin : & str ,
6060 completer : & str ,
6161 buf : & mut dyn Write ,
6262) -> Result < ( ) , Error > {
6363 writeln ! (
6464 buf,
6565 r#"
66- # Determines whether the completer for {name} is supposed to handle the command line
67- def handles [
68- spans: list # The spans that were passed to the external completer closure
69- ]: nothing -> bool {{
70- ($spans | get --optional 0) == r#'{bin}'#
71- }}
72-
7366# Performs the completion for {name}
74- def complete [
75- spans: list # The spans that were passed to the external completer closure
67+ def {name}-completer [
68+ spans: list<string> # The spans that were passed to the external completer closure
7669]: nothing -> list {{
7770 {var}=nushell ^r#'{completer}'# -- ...$spans | from json
7871}}
7972
80- # Installs this module as an external completer for {name} globally.
81- #
82- # For commands other {name}, it will fall back to whatever external completer
83- # was defined previously (if any).
84- $env.config = $env.config
85- | upsert completions.external.enable true
86- | upsert completions.external.completer {{ |original_config|
87- let previous_completer = $original_config
88- | get --optional completions.external.completer
89- | default {{ |spans| null }}
90- {{ |spans|
91- if (handles $spans) {{
92- complete $spans
93- }} else {{
94- do $previous_completer $spans
95- }}
96- }}
97- }}
73+ @complete {name}-completer
74+ def --wrapped {name} [...args] {{
75+ ^r#'{completer}'# ...$args
76+ }}
9877"#
9978 )
10079}
You can’t perform that action at this time.
0 commit comments