@clerc/plugin-completions 0.35.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -21
  2. package/dist/index.js +7 -7
  3. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Ray <https://github.com/so1ve>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Ray <https://github.com/so1ve>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import{definePlugin as p}from"@clerc/core";const c=e=>`
2
2
  ${e})
3
3
  cmd+="__${e}"
4
- ;;`,$=e=>{const{cli:n}=e,{_name:t,_commands:o}=n;return`_${t}() {
4
+ ;;`,$=e=>{const{cli:o}=e,{_name:t,_commands:n}=o;return`_${t}() {
5
5
  local i cur prev opts cmds
6
6
  COMPREPLY=()
7
7
  cur="\${COMP_WORDS[COMP_CWORD]}"
@@ -15,7 +15,7 @@ import{definePlugin as p}from"@clerc/core";const c=e=>`
15
15
  "$1")
16
16
  cmd="${t}"
17
17
  ;;
18
- ${Object.keys(o).map(c).join("")}
18
+ ${Object.keys(n).map(c).join("")}
19
19
  *)
20
20
  ;;
21
21
  esac
@@ -23,9 +23,9 @@ ${Object.keys(o).map(c).join("")}
23
23
  }
24
24
 
25
25
  complete -F _${t} -o bashdefault -o default ${t}
26
- `},i=e=>e.replace(/([A-Z])/g,(n,t)=>`-${t.toLowerCase()}`),r=e=>e.length<=1?`-${e}`:`--${i(e)}`,a="(No Description)",u=e=>`[CompletionResult]::new('${e.name}', '${e.name}', [CompletionResultType]::ParameterValue, '${e.description}')`,d=e=>Object.entries(e.flags||{}).map(([n,t])=>{const o=[`[CompletionResult]::new('${r(n)}', '${i(n)}', [CompletionResultType]::ParameterName, '${e.flags[n].description||a}')`];return t!=null&&t.alias&&o.push(`[CompletionResult]::new('${r(t.alias)}', '${t.alias}', [CompletionResultType]::ParameterName, '${e.flags[n].description||a}')`),o.join(`
26
+ `},i=e=>e.replace(/([A-Z])/g,(o,t)=>`-${t.toLowerCase()}`),r=e=>e.length<=1?`-${e}`:`--${i(e)}`,a="(No Description)",u=e=>`[CompletionResult]::new('${e.name}', '${e.name}', [CompletionResultType]::ParameterValue, '${e.description}')`,d=e=>{var o;return Object.entries((o=e.flags)!=null?o:{}).map(([t,n])=>{const s=[`[CompletionResult]::new('${r(t)}', '${i(t)}', [CompletionResultType]::ParameterName, '${e.flags[t].description||a}')`];return n!=null&&n.alias&&s.push(`[CompletionResult]::new('${r(n.alias)}', '${n.alias}', [CompletionResultType]::ParameterName, '${e.flags[t].description||a}')`),s.join(`
27
27
  `)}).join(`
28
- `),C=e=>{const{cli:n}=e,{_name:t,_commands:o}=n;return`using namespace System.Management.Automation
28
+ `)},C=e=>{const{cli:o}=e,{_name:t,_commands:n}=o;return`using namespace System.Management.Automation
29
29
  using namespace System.Management.Automation.Language
30
30
 
31
31
  Register-ArgumentCompleter -Native -CommandName '${t}' -ScriptBlock {
@@ -47,11 +47,11 @@ Register-ArgumentCompleter -Native -CommandName '${t}' -ScriptBlock {
47
47
 
48
48
  $completions = @(switch ($command) {
49
49
  '${t}' {
50
- ${Object.entries(o).map(([s,m])=>u(m)).join(`
50
+ ${Object.entries(n).map(([s,m])=>u(m)).join(`
51
51
  `)}
52
52
  break
53
53
  }
54
- ${Object.entries(o).map(([s,m])=>`'${t};${s.split(" ").join(";")}' {
54
+ ${Object.entries(n).map(([s,m])=>`'${t};${s.split(" ").join(";")}' {
55
55
  ${d(m)}
56
56
  break
57
57
  }`).join(`
@@ -60,4 +60,4 @@ Register-ArgumentCompleter -Native -CommandName '${t}' -ScriptBlock {
60
60
 
61
61
  $completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
62
62
  Sort-Object -Property ListItemText
63
- }`},l={bash:$,pwsh:C},g=(e={})=>p({setup:n=>{const{command:t=!0}=e;return t&&(n=n.command("completions","Print shell completions to stdout",{flags:{shell:{description:"Shell type",type:String,default:""}},parameters:["[shell]"]}).on("completions",o=>{if(!n._name)throw new Error("CLI name is not defined!");const s=String(o.parameters.shell||o.flags.shell);if(!s)throw new Error("Missing shell name");if(s in l)process.stdout.write(l[s](o));else throw new Error(`No such shell: ${s}`)})),n}});export{g as completionsPlugin};
63
+ }`},l={bash:$,pwsh:C},g=(e={})=>p({setup:o=>{const{command:t=!0}=e;return t&&(o=o.command("completions","Print shell completions to stdout",{flags:{shell:{description:"Shell type",type:String,default:""}},parameters:["[shell]"]}).on("completions",n=>{var s;if(!o._name)throw new Error("CLI name is not defined!");const m=String((s=n.parameters.shell)!=null?s:n.flags.shell);if(!m)throw new Error("Missing shell name");if(m in l)process.stdout.write(l[m](n));else throw new Error(`No such shell: ${m}`)})),o}});export{g as completionsPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/plugin-completions",
3
- "version": "0.35.0",
3
+ "version": "0.37.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "description": "Clerc plugin completions",
6
6
  "keywords": [
@@ -51,8 +51,8 @@
51
51
  "@clerc/core": "*"
52
52
  },
53
53
  "devDependencies": {
54
- "@clerc/core": "0.35.0",
55
- "@clerc/utils": "0.35.0"
54
+ "@clerc/core": "0.37.0",
55
+ "@clerc/utils": "0.37.0"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "puild --minify",