@clerc/plugin-completions 0.38.0 → 0.40.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 (2) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +5 -5
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:o}=e,{_name:t,_commands:n}=o;return`_${t}() {
4
+ ;;`,$=e=>{const{cli:o}=e,{_scriptName:t,_commands:n}=o;return`_${t}() {
5
5
  local i cur prev opts cmds
6
6
  COMPREPLY=()
7
7
  cur="\${COMP_WORDS[COMP_CWORD]}"
@@ -25,7 +25,7 @@ ${Object.keys(n).map(c).join("")}
25
25
  complete -F _${t} -o bashdefault -o default ${t}
26
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:o}=e,{_name:t,_commands:n}=o;return`using namespace System.Management.Automation
28
+ `)},C=e=>{const{cli:o}=e,{_scriptName: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 {
@@ -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: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};
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._scriptName)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.38.0",
3
+ "version": "0.40.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "description": "Clerc plugin completions",
6
6
  "keywords": [
@@ -51,11 +51,11 @@
51
51
  "@clerc/core": "*"
52
52
  },
53
53
  "devDependencies": {
54
- "@clerc/core": "0.38.0",
55
- "@clerc/utils": "0.38.0"
54
+ "@clerc/core": "0.40.0",
55
+ "@clerc/utils": "0.40.0"
56
56
  },
57
57
  "scripts": {
58
- "build": "puild --minify",
59
- "watch": "puild --watch"
58
+ "build": "pkgroll --minify",
59
+ "watch": "pkgroll --watch"
60
60
  }
61
61
  }