@clerc/plugin-completions
Advanced tools
Comparing version 0.28.1 to 0.29.0
@@ -26,3 +26,3 @@ import{definePlugin as p}from"@clerc/core";const c=e=>` | ||
complete -F _${t} -o bashdefault -o default ${t} | ||
`},i=e=>e.replace(/([A-Z])/g,(n,t)=>`-${t.toLowerCase()}`),r=e=>e.length<=1?`-${e}`:`--${i(e)}`,l="(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||l}')`];return t!=null&&t.alias&&o.push(`[CompletionResult]::new('${r(t.alias)}', '${t.alias}', [CompletionResultType]::ParameterName, '${e.flags[n].description||l}')`),o.join(` | ||
`},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(` | ||
`)}).join(` | ||
@@ -64,2 +64,2 @@ `),C=e=>{const{cli:n}=e,{_name:t,_commands:o}=n;return`using namespace System.Management.Automation | ||
Sort-Object -Property ListItemText | ||
}`},a={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 a)process.stdout.write(a[s](o));else throw new Error(`No such shell: ${s}`)})),n}});export{g as completionsPlugin}; | ||
}`},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}; |
{ | ||
"name": "@clerc/plugin-completions", | ||
"version": "0.28.1", | ||
"version": "0.29.0", | ||
"author": "Ray <nn_201312@163.com> (https://github.com/so1ve)", | ||
@@ -54,4 +54,4 @@ "description": "Clerc plugin completions", | ||
"devDependencies": { | ||
"@clerc/core": "0.28.1", | ||
"@clerc/utils": "0.28.1" | ||
"@clerc/core": "0.29.0", | ||
"@clerc/utils": "0.29.0" | ||
}, | ||
@@ -58,0 +58,0 @@ "scripts": { |