@clerc/plugin-help 0.40.0 → 0.41.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.
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/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @clerc/plugin-help
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/@clerc/plugin-help?color=a1b858&label=)](https://www.npmjs.com/package/@clerc/plugin-help)
4
+
5
+ Clerc plugin to add help command to your cli.
6
+
7
+ ## 📦 Installation
8
+
9
+ ```bash
10
+ $ npm install @clerc/plugin-help
11
+ $ yarn add @clerc/plugin-help
12
+ $ pnpm add @clerc/plugin-help
13
+ ```
14
+
15
+ ## 🚀 Usage
16
+
17
+ ```ts
18
+ import { helpPlugin } from "@clerc/plugin-help";
19
+
20
+ cli.use(helpPlugin());
21
+ ```
22
+
23
+ ## 📝 License
24
+
25
+ [MIT](../../LICENSE). Made with ❤️ by [Ray](https://github.com/so1ve)
package/dist/index.d.ts CHANGED
@@ -48,21 +48,13 @@ interface HelpPluginOptions {
48
48
  * @default true
49
49
  */
50
50
  showHelpWhenNoCommand?: boolean;
51
- /**
52
- * Global notes.
53
- */
51
+ /** Global notes. */
54
52
  notes?: string[];
55
- /**
56
- * Global examples.
57
- */
53
+ /** Global examples. */
58
54
  examples?: [string, string][];
59
- /**
60
- * Banner.
61
- */
55
+ /** Banner. */
62
56
  banner?: string;
63
- /**
64
- * Renderers.
65
- */
57
+ /** Renderers. */
66
58
  renderers?: Renderers;
67
59
  }
68
60
  declare const helpPlugin: ({ command, flag, showHelpWhenNoCommand, notes, examples, banner, renderers, }?: HelpPluginOptions) => _clerc_core.Plugin<_clerc_core.Clerc<{}, {}>, _clerc_core.Clerc<{}, {}>>;
package/dist/index.js CHANGED
@@ -1,9 +1,372 @@
1
- import{Root as s,resolveFlattenCommands as G,formatCommandName as c,definePlugin as q,withBrackets as J,NoSuchCommandError as U}from"@clerc/core";import V from"node:tty";const N=u=>Array.isArray(u)?u:[u],K=u=>u.replace(/([A-Z])/g,(F,E)=>`-${E.toLowerCase()}`),j=u=>u.length<=1?`-${u}`:`--${K(u)}`,Q=(u,F)=>F.length!==u.length?!1:u.every((E,B)=>E===F[B]);function X(u,F,E){if(F===s)return[u[s],s];const B=N(F),e=G(u,E);let t,D;return e.forEach((x,o)=>{o===s||D===s||Q(B,o)&&(t=x,D=o)}),[t,D]}const Y=V.WriteStream.prototype.hasColors(),p=(u,F)=>Y?E=>"\x1B["+u+"m"+E+"\x1B["+F+"m":E=>E,S=p(1,22),DD=p(31,39),uD=p(32,39),L=p(33,39),FD=p(34,39),O=p(35,39),CD=p(36,39),ED={en:{"help.name":"Name:","help.version":"Version:","help.subcommand":"Subcommand:","help.commands":"Commands:","help.globalFlags":"Global Flags:","help.flags":"Flags:","help.description":"Description:","help.usage":"Usage:","help.examples":"Examples:","help.notes":"Notes:","help.noDescription":"(No description)","help.notes.1":"If no command is specified, show help for the CLI.","help.notes.2":"If a command is specified, show help for the command.","help.notes.3":"-h is an alias for --help.","help.examples.1":"Show help","help.examples.2":"Show help for a specific command","help.commandDescription":"Show help","help.default":"Default: %s"},"zh-CN":{"help.name":"\u540D\u79F0:","help.version":"\u7248\u672C:","help.subcommand":"\u5B50\u547D\u4EE4:","help.commands":"\u547D\u4EE4:","help.globalFlags":"\u5168\u5C40\u6807\u5FD7:","help.flags":"\u6807\u5FD7:","help.description":"\u63CF\u8FF0:","help.usage":"\u4F7F\u7528:","help.examples":"\u793A\u4F8B:","help.notes":"\u5907\u6CE8:","help.noDescription":"(\u65E0\u63CF\u8FF0)","help.notes.1":"\u5982\u679C\u6CA1\u6709\u6307\u5B9A\u5C55\u793A\u54EA\u4E2A\u547D\u4EE4\u7684\u5E2E\u52A9\u4FE1\u606F\uFF0C\u9ED8\u8BA4\u5C55\u793ACLI\u7684\u3002","help.notes.2":"\u5982\u679C\u6307\u5B9A\u4E86\u5219\u5C55\u793A\u8BE5\u547D\u4EE4\u5E2E\u52A9\u4FE1\u606F\u3002","help.notes.3":"-h \u662F --help \u7684\u4E00\u4E2A\u522B\u540D\u3002","help.examples.1":"\u5C55\u793A CLI \u7684\u5E2E\u52A9\u4FE1\u606F","help.examples.2":"\u5C55\u793A\u6307\u5B9A\u547D\u4EE4\u7684\u5E2E\u52A9\u4FE1\u606F","help.commandDescription":"\u5C55\u793A\u5E2E\u52A9\u4FE1\u606F","help.default":"\u9ED8\u8BA4\u503C: %s"}};function eD({onlyFirst:u=!1}={}){const F=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(F,u?void 0:"g")}function BD(u){if(typeof u!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof u}\``);return u.replace(eD(),"")}function g(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var v={exports:{}};v.exports,function(u){var F={};u.exports=F,F.eastAsianWidth=function(B){var e=B.charCodeAt(0),t=B.length==2?B.charCodeAt(1):0,D=e;return 55296<=e&&e<=56319&&56320<=t&&t<=57343&&(e&=1023,t&=1023,D=e<<10|t,D+=65536),D==12288||65281<=D&&D<=65376||65504<=D&&D<=65510?"F":D==8361||65377<=D&&D<=65470||65474<=D&&D<=65479||65482<=D&&D<=65487||65490<=D&&D<=65495||65498<=D&&D<=65500||65512<=D&&D<=65518?"H":4352<=D&&D<=4447||4515<=D&&D<=4519||4602<=D&&D<=4607||9001<=D&&D<=9002||11904<=D&&D<=11929||11931<=D&&D<=12019||12032<=D&&D<=12245||12272<=D&&D<=12283||12289<=D&&D<=12350||12353<=D&&D<=12438||12441<=D&&D<=12543||12549<=D&&D<=12589||12593<=D&&D<=12686||12688<=D&&D<=12730||12736<=D&&D<=12771||12784<=D&&D<=12830||12832<=D&&D<=12871||12880<=D&&D<=13054||13056<=D&&D<=19903||19968<=D&&D<=42124||42128<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||55216<=D&&D<=55238||55243<=D&&D<=55291||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65106||65108<=D&&D<=65126||65128<=D&&D<=65131||110592<=D&&D<=110593||127488<=D&&D<=127490||127504<=D&&D<=127546||127552<=D&&D<=127560||127568<=D&&D<=127569||131072<=D&&D<=194367||177984<=D&&D<=196605||196608<=D&&D<=262141?"W":32<=D&&D<=126||162<=D&&D<=163||165<=D&&D<=166||D==172||D==175||10214<=D&&D<=10221||10629<=D&&D<=10630?"Na":D==161||D==164||167<=D&&D<=168||D==170||173<=D&&D<=174||176<=D&&D<=180||182<=D&&D<=186||188<=D&&D<=191||D==198||D==208||215<=D&&D<=216||222<=D&&D<=225||D==230||232<=D&&D<=234||236<=D&&D<=237||D==240||242<=D&&D<=243||247<=D&&D<=250||D==252||D==254||D==257||D==273||D==275||D==283||294<=D&&D<=295||D==299||305<=D&&D<=307||D==312||319<=D&&D<=322||D==324||328<=D&&D<=331||D==333||338<=D&&D<=339||358<=D&&D<=359||D==363||D==462||D==464||D==466||D==468||D==470||D==472||D==474||D==476||D==593||D==609||D==708||D==711||713<=D&&D<=715||D==717||D==720||728<=D&&D<=731||D==733||D==735||768<=D&&D<=879||913<=D&&D<=929||931<=D&&D<=937||945<=D&&D<=961||963<=D&&D<=969||D==1025||1040<=D&&D<=1103||D==1105||D==8208||8211<=D&&D<=8214||8216<=D&&D<=8217||8220<=D&&D<=8221||8224<=D&&D<=8226||8228<=D&&D<=8231||D==8240||8242<=D&&D<=8243||D==8245||D==8251||D==8254||D==8308||D==8319||8321<=D&&D<=8324||D==8364||D==8451||D==8453||D==8457||D==8467||D==8470||8481<=D&&D<=8482||D==8486||D==8491||8531<=D&&D<=8532||8539<=D&&D<=8542||8544<=D&&D<=8555||8560<=D&&D<=8569||D==8585||8592<=D&&D<=8601||8632<=D&&D<=8633||D==8658||D==8660||D==8679||D==8704||8706<=D&&D<=8707||8711<=D&&D<=8712||D==8715||D==8719||D==8721||D==8725||D==8730||8733<=D&&D<=8736||D==8739||D==8741||8743<=D&&D<=8748||D==8750||8756<=D&&D<=8759||8764<=D&&D<=8765||D==8776||D==8780||D==8786||8800<=D&&D<=8801||8804<=D&&D<=8807||8810<=D&&D<=8811||8814<=D&&D<=8815||8834<=D&&D<=8835||8838<=D&&D<=8839||D==8853||D==8857||D==8869||D==8895||D==8978||9312<=D&&D<=9449||9451<=D&&D<=9547||9552<=D&&D<=9587||9600<=D&&D<=9615||9618<=D&&D<=9621||9632<=D&&D<=9633||9635<=D&&D<=9641||9650<=D&&D<=9651||9654<=D&&D<=9655||9660<=D&&D<=9661||9664<=D&&D<=9665||9670<=D&&D<=9672||D==9675||9678<=D&&D<=9681||9698<=D&&D<=9701||D==9711||9733<=D&&D<=9734||D==9737||9742<=D&&D<=9743||9748<=D&&D<=9749||D==9756||D==9758||D==9792||D==9794||9824<=D&&D<=9825||9827<=D&&D<=9829||9831<=D&&D<=9834||9836<=D&&D<=9837||D==9839||9886<=D&&D<=9887||9918<=D&&D<=9919||9924<=D&&D<=9933||9935<=D&&D<=9953||D==9955||9960<=D&&D<=9983||D==10045||D==10071||10102<=D&&D<=10111||11093<=D&&D<=11097||12872<=D&&D<=12879||57344<=D&&D<=63743||65024<=D&&D<=65039||D==65533||127232<=D&&D<=127242||127248<=D&&D<=127277||127280<=D&&D<=127337||127344<=D&&D<=127386||917760<=D&&D<=917999||983040<=D&&D<=1048573||1048576<=D&&D<=1114109?"A":"N"},F.characterLength=function(B){var e=this.eastAsianWidth(B);return e=="F"||e=="W"||e=="A"?2:1};function E(B){return B.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}F.length=function(B){for(var e=E(B),t=0,D=0;D<e.length;D++)t=t+this.characterLength(e[D]);return t},F.slice=function(B,e,t){textLen=F.length(B),e=e||0,t=t||1,e<0&&(e=textLen+e),t<0&&(t=textLen+t);for(var D="",x=0,o=E(B),r=0;r<o.length;r++){var n=o[r],C=F.length(n);if(x>=e-(C==2?1:0))if(x+C<=t)D+=n;else break;x+=C}return D}}(v);var tD=v.exports,nD=g(tD),xD=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\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\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\u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uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},rD=g(xD);function oD(u,F={}){if(typeof u!="string"||u.length===0||(F={ambiguousIsNarrow:!0,...F},u=BD(u),u.length===0))return 0;u=u.replace(rD()," ");const E=F.ambiguousIsNarrow?1:2;let B=0;for(const e of u){const t=e.codePointAt(0);if(t<=31||t>=127&&t<=159||t>=768&&t<=879)continue;switch(nD.eastAsianWidth(e)){case"F":case"W":B+=2;break;case"A":B+=E;break;default:B+=1}}return B}var aD=function(u,F){F||(F={});var E=F.hsep===void 0?" ":F.hsep,B=F.align||[],e=F.stringLength||function(o){return String(o).length},t=W(u,function(o,r){return T(r,function(n,C){var a=R(n);(!o[C]||a>o[C])&&(o[C]=a)}),o},[]),D=f(u,function(o){return f(o,function(r,n){var C=String(r);if(B[n]==="."){var a=R(C),A=t[n]+(/\./.test(C)?1:2)-(e(C)-a);return C+Array(A).join(" ")}else return C})}),x=W(D,function(o,r){return T(r,function(n,C){var a=e(n);(!o[C]||a>o[C])&&(o[C]=a)}),o},[]);return f(D,function(o){return f(o,function(r,n){var C=x[n]-e(r)||0,a=Array(Math.max(C+1,1)).join(" ");return B[n]==="r"||B[n]==="."?a+r:B[n]==="c"?Array(Math.ceil(C/2+1)).join(" ")+r+Array(Math.floor(C/2+1)).join(" "):r+a}).join(E).replace(/\s+$/,"")}).join(`
2
- `)};function R(u){var F=/\.[^.]*$/.exec(u);return F?F.index+1:u.length}function W(u,F,E){if(u.reduce)return u.reduce(F,E);for(var B=0,e=arguments.length>=3?E:u[B++];B<u.length;B++)F(e,u[B],B);return e}function T(u,F){if(u.forEach)return u.forEach(F);for(var E=0;E<u.length;E++)F.call(u,u[E],E)}function f(u,F){if(u.map)return u.map(F);for(var E=[],B=0;B<u.length;B++)E.push(F.call(u,u[B],B));return E}var AD=g(aD);const y=u=>AD(u,{stringLength:oD}),h=u=>y(u).split(`
3
- `),I=new Map([[Boolean,void 0],[String,"string"],[Number,"number"]]),sD=(u,F=!1)=>{const E=I.has(u)?I.get(u):"value";return E?F?`[${E}]`:`<${E}>`:""},lD=(u,F)=>u===s?-1:F===s?1:u.length-F.length,b=L("-"),M=u=>{process.stdout.write(u)},$=(u,F,E)=>{var B;const{t:e}=F.i18n,t=[{title:e("help.name"),body:DD(F._name)},{title:e("help.version"),body:L(F._version)}];E&&t.push({title:e("help.subcommand"),body:uD(`${F._scriptName} ${c(E.name)}`)}),u.push({type:"inline",items:t}),u.push({title:e("help.description"),body:[(B=E==null?void 0:E.description)!=null?B:F._description]})},P=(u,F,E)=>{const B=F.map(([e,t])=>[e,b,t]);u.push({title:E("help.examples"),body:h(B)})},_=(u,F,E)=>Object.entries(u).map(([B,e])=>{const t=e.default!==void 0;let D=[j(B)];e.alias&&D.push(j(e.alias)),D=D.map(E.renderFlagName);const x=[FD(D.join(", ")),E.renderType(e.type,t)];return x.push(b,e.description||F("help.noDescription")),t&&x.push(`(${F("help.default",E.renderDefault(e.default))})`),x}),i=u=>{const F=[];for(const E of u){if(E.type==="block"||!E.type){const B=" ",e=E.body.map(D=>B+D);e.unshift("");const t=e.join(`
4
- `);F.push(y([[S(`${E.title}`)],[t]]).toString())}else if(E.type==="inline"){const B=E.items.map(t=>[S(`${t.title}`),t.body]),e=y(B);F.push(e.toString())}F.push("")}return F.join(`
5
- `)},z={renderFlagName:u=>u,renderSections:u=>u,renderType:(u,F)=>sD(u,F),renderDefault:u=>JSON.stringify(u)},m=(u,F,E,B,e)=>{const{cli:t}=F,{t:D}=t.i18n;let x=[];const o=Object.assign(Object.create(null),z,e);$(x,t),x.push({title:D("help.usage"),body:[O(`$ ${t._scriptName} ${J("command",F.hasRootOrAlias)} [flags]`)]});const r=[...F.hasRoot?[t._commands[s]]:[],...Object.values(t._commands)].map(C=>{var a;const A=[typeof C.name=="symbol"?"":C.name,...N((a=C.alias)!=null?a:[])].sort(lD).map(l=>l===""||typeof l=="symbol"?`${t._scriptName}`:`${t._scriptName} ${l}`).join(", ");return[CD(A),b,C.description]});r.length&&x.push({title:D("help.commands"),body:h(r)});const n=_(t._flags,D,o);return n.length&&x.push({title:D("help.globalFlags"),body:h(n)}),E&&x.push({title:D("help.notes"),body:E}),B&&P(x,B,D),x=o.renderSections(x),u(x)},d=(u,F,E)=>{var B,e,t,D,x,o;const{cli:r}=F,{t:n}=r.i18n,[C]=X(r._commands,E,n);if(!C)throw new U(c(E),n);const a=Object.assign(Object.create(null),z,(B=C.help)==null?void 0:B.renderers);let A=[];E===s?$(A,r):$(A,r,{...C,name:c(E)});const l=(t=(e=C.parameters)==null?void 0:e.join(" "))!=null?t:void 0,k=E===s?"":` ${c(E)}`,H=l?` ${l}`:"",Z=C.flags?" [flags]":"";A.push({title:n("help.usage"),body:[O(`$ ${r._scriptName}${k}${H}${Z}`)]});const w=_(r._flags,n,a);return w.length&&A.push({title:n("help.globalFlags"),body:h(w)}),C.flags&&A.push({title:n("help.flags"),body:h(_(C.flags,n,a))}),(D=C==null?void 0:C.help)!=null&&D.notes&&A.push({title:n("help.notes"),body:C.help.notes}),(x=C==null?void 0:C.help)!=null&&x.examples&&P(A,(o=C==null?void 0:C.help)==null?void 0:o.examples,n),A=a.renderSections(A),u(A)},iD=({command:u=!0,flag:F=!0,showHelpWhenNoCommand:E=!0,notes:B,examples:e,banner:t,renderers:D}={})=>q({setup:x=>{const{add:o,t:r}=x.i18n;o(ED);const n=C=>{t&&M(`${t}
6
- `),M(C)};return u&&(x=x.command("help",r("help.commandDescription"),{parameters:["[command...]"],help:{notes:[r("help.notes.1"),r("help.notes.2"),r("help.notes.3")],examples:[[`$ ${x._scriptName} help`,r("help.examples.1")],[`$ ${x._scriptName} help <command>`,r("help.examples.2")],[`$ ${x._scriptName} <command> --help`,r("help.examples.2")]]}}).on("help",C=>{C.parameters.command.length?n(d(i,C,C.parameters.command)):n(m(i,C,B,e,D))})),F&&(x=x.flag("help",r("help.commandDescription"),{alias:"h",type:Boolean,default:!1})),x.inspector((C,a)=>{const A=C.flags.help;if(!C.hasRootOrAlias&&!C.raw._.length&&E&&!A){let l=`${r("core.noCommandGiven")}
7
-
8
- `;l+=m(i,C,B,e,D),l+=`
9
- `,n(l),process.exit(1)}else A?C.raw._.length?C.called!==s&&C.name===s?n(m(i,C,B,e,D)):n(d(i,C,C.raw._)):C.hasRootOrAlias?n(d(i,C,s)):n(m(i,C,B,e,D)):a()}),x}});export{iD as helpPlugin};
1
+ import { Root, formatCommandName, definePlugin, withBrackets, NoSuchCommandError } from '@clerc/core';
2
+ import { gracefulFlagName, toArray, resolveCommandStrict } from '@clerc/utils';
3
+ import * as yc from 'yoctocolors';
4
+ import stringWidth from 'string-width';
5
+ import textTable from 'text-table';
6
+
7
+ const locales = {
8
+ "en": {
9
+ "help.name": "Name:",
10
+ "help.version": "Version:",
11
+ "help.subcommand": "Subcommand:",
12
+ "help.commands": "Commands:",
13
+ "help.globalFlags": "Global Flags:",
14
+ "help.flags": "Flags:",
15
+ "help.description": "Description:",
16
+ "help.usage": "Usage:",
17
+ "help.examples": "Examples:",
18
+ "help.notes": "Notes:",
19
+ "help.noDescription": "(No description)",
20
+ "help.notes.1": "If no command is specified, show help for the CLI.",
21
+ "help.notes.2": "If a command is specified, show help for the command.",
22
+ "help.notes.3": "-h is an alias for --help.",
23
+ "help.examples.1": "Show help",
24
+ "help.examples.2": "Show help for a specific command",
25
+ "help.commandDescription": "Show help",
26
+ "help.default": "Default: %s"
27
+ },
28
+ "zh-CN": {
29
+ "help.name": "\u540D\u79F0:",
30
+ "help.version": "\u7248\u672C:",
31
+ "help.subcommand": "\u5B50\u547D\u4EE4:",
32
+ "help.commands": "\u547D\u4EE4:",
33
+ "help.globalFlags": "\u5168\u5C40\u6807\u5FD7:",
34
+ "help.flags": "\u6807\u5FD7:",
35
+ "help.description": "\u63CF\u8FF0:",
36
+ "help.usage": "\u4F7F\u7528:",
37
+ "help.examples": "\u793A\u4F8B:",
38
+ "help.notes": "\u5907\u6CE8:",
39
+ "help.noDescription": "(\u65E0\u63CF\u8FF0)",
40
+ "help.notes.1": "\u5982\u679C\u6CA1\u6709\u6307\u5B9A\u5C55\u793A\u54EA\u4E2A\u547D\u4EE4\u7684\u5E2E\u52A9\u4FE1\u606F\uFF0C\u9ED8\u8BA4\u5C55\u793ACLI\u7684\u3002",
41
+ "help.notes.2": "\u5982\u679C\u6307\u5B9A\u4E86\u5219\u5C55\u793A\u8BE5\u547D\u4EE4\u5E2E\u52A9\u4FE1\u606F\u3002",
42
+ "help.notes.3": "-h \u662F --help \u7684\u4E00\u4E2A\u522B\u540D\u3002",
43
+ "help.examples.1": "\u5C55\u793A CLI \u7684\u5E2E\u52A9\u4FE1\u606F",
44
+ "help.examples.2": "\u5C55\u793A\u6307\u5B9A\u547D\u4EE4\u7684\u5E2E\u52A9\u4FE1\u606F",
45
+ "help.commandDescription": "\u5C55\u793A\u5E2E\u52A9\u4FE1\u606F",
46
+ "help.default": "\u9ED8\u8BA4\u503C: %s"
47
+ }
48
+ };
49
+
50
+ const table = (items) => textTable(items, { stringLength: stringWidth });
51
+ const splitTable = (items) => table(items).split("\n");
52
+ const primitiveMap = /* @__PURE__ */ new Map([
53
+ [Boolean, void 0],
54
+ [String, "string"],
55
+ [Number, "number"]
56
+ ]);
57
+ function stringifyType(type, hasDefault = false) {
58
+ const res = primitiveMap.has(type) ? primitiveMap.get(type) : "value";
59
+ return res ? hasDefault ? `[${res}]` : `<${res}>` : "";
60
+ }
61
+ function sortName(a, b) {
62
+ if (a === Root) {
63
+ return -1;
64
+ }
65
+ if (b === Root) {
66
+ return 1;
67
+ }
68
+ return a.length - b.length;
69
+ }
70
+ const DELIMITER = yc.yellow("-");
71
+ function print(s) {
72
+ process.stdout.write(s);
73
+ }
74
+ function generateCliDetail(sections, cli, subcommand) {
75
+ var _a;
76
+ const { t } = cli.i18n;
77
+ const items = [
78
+ {
79
+ title: t("help.name"),
80
+ body: yc.red(cli._name)
81
+ },
82
+ {
83
+ title: t("help.version"),
84
+ body: yc.yellow(cli._version)
85
+ }
86
+ ];
87
+ if (subcommand) {
88
+ items.push({
89
+ title: t("help.subcommand"),
90
+ body: yc.green(
91
+ `${cli._scriptName} ${formatCommandName(subcommand.name)}`
92
+ )
93
+ });
94
+ }
95
+ sections.push({
96
+ type: "inline",
97
+ items
98
+ });
99
+ sections.push({
100
+ title: t("help.description"),
101
+ body: [(_a = subcommand == null ? void 0 : subcommand.description) != null ? _a : cli._description]
102
+ });
103
+ }
104
+ function generateExamples(sections, examples, t) {
105
+ const examplesFormatted = examples.map(([command, description]) => [
106
+ command,
107
+ DELIMITER,
108
+ description
109
+ ]);
110
+ sections.push({
111
+ title: t("help.examples"),
112
+ body: splitTable(examplesFormatted)
113
+ });
114
+ }
115
+ const formatFlags = (flags, t, renderers) => Object.entries(flags).map(([name, flag]) => {
116
+ const hasDefault = flag.default !== void 0;
117
+ let flagNameWithAlias = [gracefulFlagName(name)];
118
+ if (flag.alias) {
119
+ flagNameWithAlias.push(gracefulFlagName(flag.alias));
120
+ }
121
+ flagNameWithAlias = flagNameWithAlias.map(renderers.renderFlagName);
122
+ const items = [
123
+ yc.blue(flagNameWithAlias.join(", ")),
124
+ renderers.renderType(flag.type, hasDefault)
125
+ ];
126
+ items.push(DELIMITER, flag.description || t("help.noDescription"));
127
+ if (hasDefault) {
128
+ items.push(
129
+ `(${t("help.default", renderers.renderDefault(flag.default))})`
130
+ );
131
+ }
132
+ return items;
133
+ });
134
+
135
+ const render = (sections) => {
136
+ const rendered = [];
137
+ for (const section of sections) {
138
+ if (section.type === "block" || !section.type) {
139
+ const indent = " ";
140
+ const formattedBody = section.body.map((line) => indent + line);
141
+ formattedBody.unshift("");
142
+ const body = formattedBody.join("\n");
143
+ rendered.push(table([[yc.bold(`${section.title}`)], [body]]).toString());
144
+ } else if (section.type === "inline") {
145
+ const formattedBody = section.items.map((item) => [
146
+ yc.bold(`${item.title}`),
147
+ item.body
148
+ ]);
149
+ const tableGenerated = table(formattedBody);
150
+ rendered.push(tableGenerated.toString());
151
+ }
152
+ rendered.push("");
153
+ }
154
+ return rendered.join("\n");
155
+ };
156
+ const noop = (x) => x;
157
+ const defaultRenderers = {
158
+ renderFlagName: noop,
159
+ renderSections: noop,
160
+ renderType: stringifyType,
161
+ renderDefault: JSON.stringify
162
+ };
163
+
164
+ function generateHelp(render2, ctx, notes, examples, _renderers) {
165
+ const { cli } = ctx;
166
+ const { t } = cli.i18n;
167
+ let sections = [];
168
+ const renderers = Object.assign(
169
+ /* @__PURE__ */ Object.create(null),
170
+ defaultRenderers,
171
+ _renderers
172
+ );
173
+ generateCliDetail(sections, cli);
174
+ sections.push({
175
+ title: t("help.usage"),
176
+ body: [
177
+ yc.magenta(
178
+ `$ ${cli._scriptName} ${withBrackets(
179
+ "command",
180
+ ctx.hasRootOrAlias
181
+ )} [flags]`
182
+ )
183
+ ]
184
+ });
185
+ const commands = [
186
+ ...ctx.hasRoot ? [cli._commands[Root]] : [],
187
+ ...Object.values(cli._commands)
188
+ ].map((command) => {
189
+ var _a;
190
+ const commandNameWithAlias = [
191
+ typeof command.name === "symbol" ? "" : command.name,
192
+ ...toArray((_a = command.alias) != null ? _a : [])
193
+ ].sort(sortName).map(
194
+ (n) => n === "" || typeof n === "symbol" ? `${cli._scriptName}` : `${cli._scriptName} ${n}`
195
+ ).join(", ");
196
+ return [yc.cyan(commandNameWithAlias), DELIMITER, command.description];
197
+ });
198
+ if (commands.length > 0) {
199
+ sections.push({
200
+ title: t("help.commands"),
201
+ body: splitTable(commands)
202
+ });
203
+ }
204
+ const globalFlags = formatFlags(cli._flags, t, renderers);
205
+ if (globalFlags.length > 0) {
206
+ sections.push({
207
+ title: t("help.globalFlags"),
208
+ body: splitTable(globalFlags)
209
+ });
210
+ }
211
+ if (notes) {
212
+ sections.push({
213
+ title: t("help.notes"),
214
+ body: notes
215
+ });
216
+ }
217
+ if (examples) {
218
+ generateExamples(sections, examples, t);
219
+ }
220
+ sections = renderers.renderSections(sections);
221
+ return render2(sections);
222
+ }
223
+ function generateSubcommandHelp(render2, ctx, command) {
224
+ var _a, _b, _c, _d, _e, _f;
225
+ const { cli } = ctx;
226
+ const { t } = cli.i18n;
227
+ const [subcommand] = resolveCommandStrict(cli._commands, command, t);
228
+ if (!subcommand) {
229
+ throw new NoSuchCommandError(formatCommandName(command), t);
230
+ }
231
+ const renderers = Object.assign(
232
+ /* @__PURE__ */ Object.create(null),
233
+ defaultRenderers,
234
+ (_a = subcommand.help) == null ? void 0 : _a.renderers
235
+ );
236
+ let sections = [];
237
+ if (command === Root) {
238
+ generateCliDetail(sections, cli);
239
+ } else {
240
+ generateCliDetail(sections, cli, {
241
+ ...subcommand,
242
+ name: formatCommandName(command)
243
+ });
244
+ }
245
+ const parameters = (_c = (_b = subcommand.parameters) == null ? void 0 : _b.join(" ")) != null ? _c : void 0;
246
+ const commandName = command === Root ? "" : ` ${formatCommandName(command)}`;
247
+ const parametersString = parameters ? ` ${parameters}` : "";
248
+ const flagsString = subcommand.flags ? " [flags]" : "";
249
+ sections.push({
250
+ title: t("help.usage"),
251
+ body: [
252
+ yc.magenta(
253
+ `$ ${cli._scriptName}${commandName}${parametersString}${flagsString}`
254
+ )
255
+ ]
256
+ });
257
+ const globalFlags = formatFlags(cli._flags, t, renderers);
258
+ if (globalFlags.length > 0) {
259
+ sections.push({
260
+ title: t("help.globalFlags"),
261
+ body: splitTable(globalFlags)
262
+ });
263
+ }
264
+ if (subcommand.flags) {
265
+ sections.push({
266
+ title: t("help.flags"),
267
+ body: splitTable(formatFlags(subcommand.flags, t, renderers))
268
+ });
269
+ }
270
+ if ((_d = subcommand == null ? void 0 : subcommand.help) == null ? void 0 : _d.notes) {
271
+ sections.push({
272
+ title: t("help.notes"),
273
+ body: subcommand.help.notes
274
+ });
275
+ }
276
+ if ((_e = subcommand == null ? void 0 : subcommand.help) == null ? void 0 : _e.examples) {
277
+ generateExamples(sections, (_f = subcommand == null ? void 0 : subcommand.help) == null ? void 0 : _f.examples, t);
278
+ }
279
+ sections = renderers.renderSections(sections);
280
+ return render2(sections);
281
+ }
282
+ const helpPlugin = ({
283
+ command = true,
284
+ flag = true,
285
+ showHelpWhenNoCommand = true,
286
+ notes,
287
+ examples,
288
+ banner,
289
+ renderers
290
+ } = {}) => definePlugin({
291
+ setup: (cli) => {
292
+ const { add, t } = cli.i18n;
293
+ add(locales);
294
+ function printHelp(s) {
295
+ banner && print(`${banner}
296
+ `);
297
+ print(s);
298
+ }
299
+ if (command) {
300
+ cli = cli.command("help", t("help.commandDescription"), {
301
+ parameters: ["[command...]"],
302
+ help: {
303
+ notes: [
304
+ t("help.notes.1"),
305
+ t("help.notes.2"),
306
+ t("help.notes.3")
307
+ ],
308
+ examples: [
309
+ [`$ ${cli._scriptName} help`, t("help.examples.1")],
310
+ [`$ ${cli._scriptName} help <command>`, t("help.examples.2")],
311
+ [
312
+ `$ ${cli._scriptName} <command> --help`,
313
+ t("help.examples.2")
314
+ ]
315
+ ]
316
+ }
317
+ }).on("help", (ctx) => {
318
+ if (ctx.parameters.command.length > 0) {
319
+ printHelp(
320
+ generateSubcommandHelp(render, ctx, ctx.parameters.command)
321
+ );
322
+ } else {
323
+ printHelp(generateHelp(render, ctx, notes, examples, renderers));
324
+ }
325
+ });
326
+ }
327
+ if (flag) {
328
+ cli = cli.flag("help", t("help.commandDescription"), {
329
+ alias: "h",
330
+ type: Boolean,
331
+ default: false
332
+ });
333
+ }
334
+ cli.inspector((ctx, next) => {
335
+ const shouldShowHelp = ctx.flags.help;
336
+ if (!ctx.hasRootOrAlias && ctx.raw._.length === 0 && showHelpWhenNoCommand && !shouldShowHelp) {
337
+ let str = `${t("core.noCommandGiven")}
338
+
339
+ `;
340
+ str += generateHelp(render, ctx, notes, examples, renderers);
341
+ str += "\n";
342
+ printHelp(str);
343
+ process.exit(1);
344
+ } else if (shouldShowHelp) {
345
+ if (ctx.raw._.length > 0) {
346
+ if (ctx.called === Root) {
347
+ printHelp(generateSubcommandHelp(render, ctx, ctx.raw._));
348
+ } else {
349
+ if (ctx.name === Root) {
350
+ printHelp(
351
+ generateHelp(render, ctx, notes, examples, renderers)
352
+ );
353
+ } else {
354
+ printHelp(generateSubcommandHelp(render, ctx, ctx.raw._));
355
+ }
356
+ }
357
+ } else {
358
+ if (ctx.hasRootOrAlias) {
359
+ printHelp(generateSubcommandHelp(render, ctx, Root));
360
+ } else {
361
+ printHelp(generateHelp(render, ctx, notes, examples, renderers));
362
+ }
363
+ }
364
+ } else {
365
+ next();
366
+ }
367
+ });
368
+ return cli;
369
+ }
370
+ });
371
+
372
+ export { helpPlugin };
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@clerc/plugin-help",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
+ "type": "module",
5
6
  "description": "Clerc plugin help",
6
7
  "keywords": [
7
- "cli",
8
- "clerc",
9
- "clerc-plugin",
8
+ "args",
10
9
  "arguments",
11
10
  "argv",
12
- "args",
11
+ "clerc",
12
+ "clerc-plugin",
13
+ "cli",
13
14
  "terminal"
14
15
  ],
15
- "type": "module",
16
16
  "homepage": "https://github.com/so1ve/clerc/tree/main/packages/plugin-help#readme",
17
17
  "repository": {
18
18
  "type": "git",
@@ -47,19 +47,18 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "peerDependencies": {
51
- "@clerc/core": "*"
52
- },
53
- "devDependencies": {
50
+ "dependencies": {
54
51
  "@types/text-table": "^0.2.2",
55
- "string-width": "^5.1.2",
52
+ "string-width": "^6.1.0",
56
53
  "text-table": "^0.2.0",
57
54
  "yoctocolors": "^1.0.0",
58
- "@clerc/core": "0.40.0",
59
- "@clerc/utils": "0.40.0"
55
+ "@clerc/utils": "0.41.0"
56
+ },
57
+ "peerDependencies": {
58
+ "@clerc/core": "*"
60
59
  },
61
60
  "scripts": {
62
- "build": "pkgroll --minify",
61
+ "build": "pkgroll",
63
62
  "watch": "pkgroll --watch"
64
63
  }
65
64
  }