forge-terminal 0.5.5 → 0.5.6
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/README.md +26 -8
- package/dist/chunks/{about-credits-VRRE6342.js → about-credits-TM34J3IS.js} +1 -1
- package/dist/chunks/args-7OJGCKH4.js +3 -0
- package/dist/chunks/{boot-MX7UP2M2.js → boot-5KSVFF4C.js} +1 -1
- package/dist/chunks/{chunk-ZBETH6BR.js → chunk-2BPH3IL6.js} +33 -24
- package/dist/chunks/{chunk-BI2E72HM.js → chunk-2HGBB3DQ.js} +1 -1
- package/dist/chunks/{chunk-OUXPGAQL.js → chunk-37U22UEW.js} +1 -1
- package/dist/chunks/{chunk-R7BEV6PR.js → chunk-3RH2AXJW.js} +1 -1
- package/dist/chunks/{chunk-7I2OSTBX.js → chunk-4KGC5ZBZ.js} +1 -1
- package/dist/chunks/{chunk-J6AZTW62.js → chunk-4MJEEEFA.js} +1 -1
- package/dist/chunks/{chunk-YK26E3OX.js → chunk-4RNVZQRC.js} +1 -1
- package/dist/chunks/{chunk-TRJXZLR6.js → chunk-6RCS3KBP.js} +1 -1
- package/dist/chunks/{chunk-UGATQHEE.js → chunk-75GYDNAQ.js} +1 -1
- package/dist/chunks/{chunk-BU4YYGUJ.js → chunk-7R7KDE3R.js} +1 -1
- package/dist/chunks/chunk-7XFLG32B.js +3 -0
- package/dist/chunks/{chunk-2ZZXIDYX.js → chunk-CZDI37SI.js} +1 -1
- package/dist/chunks/{chunk-HACM3MAD.js → chunk-FAUL5L2W.js} +1 -1
- package/dist/chunks/{chunk-HWCXNKIN.js → chunk-HTA25PO2.js} +1 -1
- package/dist/chunks/{chunk-BROTSQXG.js → chunk-ILQDMVJR.js} +1 -1
- package/dist/chunks/chunk-JDTDXCZE.js +3 -0
- package/dist/chunks/{chunk-MES4FVLR.js → chunk-KQ2AHGLK.js} +1 -1
- package/dist/chunks/{chunk-SZCSV3PX.js → chunk-LAJAXLGQ.js} +1 -1
- package/dist/chunks/{chunk-45BFQHJB.js → chunk-LM4K7CZQ.js} +1 -1
- package/dist/chunks/chunk-N32JL4UI.js +3 -0
- package/dist/chunks/{chunk-Q7ERPAG3.js → chunk-NMECUMJD.js} +1 -1
- package/dist/chunks/chunk-POM7FXIV.js +3 -0
- package/dist/chunks/{chunk-MMLROWBQ.js → chunk-QV27SER6.js} +2 -2
- package/dist/chunks/{chunk-JJV2YXZQ.js → chunk-QYAJFKQL.js} +1 -1
- package/dist/chunks/chunk-RUAEBL2F.js +4 -0
- package/dist/chunks/chunk-TFGK7IRZ.js +19 -0
- package/dist/chunks/{chunk-OGYSMKRM.js → chunk-TLHUFIXD.js} +1 -1
- package/dist/chunks/{chunk-L5JBHB4G.js → chunk-U2XQL7AA.js} +1 -1
- package/dist/chunks/{chunk-HYMPLIHW.js → chunk-UB6YVCIS.js} +1 -1
- package/dist/chunks/{chunk-RLOJSZ6W.js → chunk-V6GWPR2A.js} +1 -1
- package/dist/chunks/{chunk-BONMSCKD.js → chunk-W43SUVWN.js} +1 -1
- package/dist/chunks/{chunk-HGJXGAGJ.js → chunk-W53XNVNH.js} +1 -1
- package/dist/chunks/{chunk-D4R7UACU.js → chunk-WBV6I7UP.js} +1 -1
- package/dist/chunks/{chunk-7KYO62XK.js → chunk-WBW6G4N6.js} +1 -1
- package/dist/chunks/{chunk-HVMQTKP6.js → chunk-WNYM6NSV.js} +1 -1
- package/dist/chunks/{chunk-WCOFUMZU.js → chunk-XY7C5I5T.js} +1 -1
- package/dist/chunks/{chunk-KDBKDURW.js → chunk-XZZCVJ64.js} +2 -2
- package/dist/chunks/chunk-YJ6XLDRA.js +3 -0
- package/dist/chunks/{chunk-7IWX5VSI.js → chunk-YR7QRQ5F.js} +1 -1
- package/dist/chunks/chunk-ZBMJTIYR.js +3 -0
- package/dist/chunks/chunk-ZJ45XUJW.js +3 -0
- package/dist/chunks/clip-command-3JBZK6Q3.js +3 -0
- package/dist/chunks/{clipboard-3VFHDKYE.js → clipboard-XOIVXPVL.js} +1 -1
- package/dist/chunks/colour-CEKEW7RV.js +3 -0
- package/dist/chunks/{command-BKAPI4A5.js → command-GAGAD65W.js} +1 -1
- package/dist/chunks/{config-command-6GXRV627.js → config-command-CKPJXJEE.js} +1 -1
- package/dist/chunks/{continue-editing-4W3XWWCE.js → continue-editing-M6WESEVB.js} +1 -1
- package/dist/chunks/{decoded-SMEHAVCH.js → decoded-XWKU23RG.js} +1 -1
- package/dist/chunks/{entry-7GW4RIK2.js → entry-64GTSHV2.js} +2 -2
- package/dist/chunks/execute-3J755YKG.js +3 -0
- package/dist/chunks/extensions-QQT6OD7W.js +3 -0
- package/dist/chunks/{extensions-command-VXZL55KR.js → extensions-command-FV3N7CBV.js} +1 -1
- package/dist/chunks/{ffmpeg-Z7JQT53Y.js → ffmpeg-VGE2QCC7.js} +1 -1
- package/dist/chunks/{image-FYCF2AVH.js → image-R5C3AWHT.js} +1 -1
- package/dist/chunks/{install-5YXQ6YV3.js → install-KGFOAQCU.js} +1 -1
- package/dist/chunks/{install-C6XNONFF.js → install-MFYGS5TG.js} +1 -1
- package/dist/chunks/{launch-U63VZQXC.js → launch-ATJNO6ZO.js} +5 -5
- package/dist/chunks/{lock-AFVXUDOM.js → lock-BG3CLOHA.js} +1 -1
- package/dist/chunks/manager-ROCFK7AS.js +4 -0
- package/dist/chunks/{needed-X5D4E5X5.js → needed-T722HOKD.js} +1 -1
- package/dist/chunks/{own-5JN35AUV.js → own-CX3EJ2AH.js} +1 -1
- package/dist/chunks/{pdfium-GKF4ES7K.js → pdfium-77L526HZ.js} +1 -1
- package/dist/chunks/{preset-command-H6G22SZD.js → preset-command-M7SESD5C.js} +1 -1
- package/dist/chunks/{registry-LLAHKI4G.js → registry-7BJ4J2SD.js} +1 -1
- package/dist/chunks/{run-WSETTQXP.js → run-GUFPETHF.js} +1 -1
- package/dist/chunks/{server-CIGFNW7X.js → server-64H64DIC.js} +18 -18
- package/dist/chunks/{theme-HAB66OAL.js → theme-S234JXQH.js} +1 -1
- package/dist/chunks/{transcribe-FVCOCTGA.js → transcribe-L64JHZ3U.js} +1 -1
- package/dist/chunks/{transcribe-command-XCBGAQMI.js → transcribe-command-Y3AHXLVA.js} +1 -1
- package/dist/chunks/{update-command-DJLYU6AB.js → update-command-DWEBUFT5.js} +1 -1
- package/dist/chunks/{update-note-47IPWQKY.js → update-note-YQD2W5B2.js} +1 -1
- package/dist/chunks/{watch-command-VL6LOERU.js → watch-command-B2Z4KSWR.js} +1 -1
- package/dist/index.js +6 -6
- package/package.json +5 -5
- package/dist/chunks/args-5BPKCNTL.js +0 -3
- package/dist/chunks/chunk-2NSUAERD.js +0 -3
- package/dist/chunks/chunk-3YWAVKDZ.js +0 -19
- package/dist/chunks/chunk-57M4J2BR.js +0 -3
- package/dist/chunks/chunk-CVNYUROW.js +0 -3
- package/dist/chunks/chunk-HFQOGB4T.js +0 -4
- package/dist/chunks/chunk-PBIS2ONZ.js +0 -3
- package/dist/chunks/chunk-QVACE4IE.js +0 -3
- package/dist/chunks/chunk-U5TEGDGH.js +0 -3
- package/dist/chunks/chunk-VTA6Z45X.js +0 -3
- package/dist/chunks/clip-command-WJ5P4DTN.js +0 -3
- package/dist/chunks/colour-5YBDFXXX.js +0 -3
- package/dist/chunks/execute-LBGFY5TG.js +0 -3
- package/dist/chunks/extensions-HTBACHMC.js +0 -3
- package/dist/chunks/manager-QUTR3RYR.js +0 -4
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ That puts `forge` on your `PATH`, so it works from any directory. Verify:
|
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
forge --version
|
|
53
|
-
# 0.5.
|
|
53
|
+
# 0.5.6
|
|
54
54
|
|
|
55
55
|
forge photo.jpg --to webp
|
|
56
56
|
```
|
|
@@ -853,6 +853,11 @@ $ forge scale 6579FD
|
|
|
853
853
|
500 #6579FD white 3.6 large · black 5.7 AA
|
|
854
854
|
…
|
|
855
855
|
950 #161B58 white 15.7 AAA · black 1.3 fails
|
|
856
|
+
$ forge card palette.csv
|
|
857
|
+
#F8F1E6 bg
|
|
858
|
+
#1C50B5 blue-600
|
|
859
|
+
…
|
|
860
|
+
$ forge card palette.csv --svg | pbcopy # then ⌘V in Figma
|
|
856
861
|
```
|
|
857
862
|
|
|
858
863
|
- **`forge palette <image>`** gives an image's main colours, most of the image
|
|
@@ -866,11 +871,21 @@ $ forge scale 6579FD
|
|
|
866
871
|
takes it (`forge scale crimson`, `forge scale 'rgb(210 4 45)'`). Pass a hex
|
|
867
872
|
without the `#`, or quote it (`'#6579FD'`): an unquoted `#` starts a
|
|
868
873
|
comment in the shell.
|
|
874
|
+
- **`forge card <file>`** reads named colours you already have and draws
|
|
875
|
+
them as the same card, so a colour system written down pastes into Figma
|
|
876
|
+
in one go. It takes design tokens (JSON), a CSV with name and hex columns,
|
|
877
|
+
CSS variables, or one colour a line (`bg #F8F1E6`, `ink: rgb(30 26 21)`).
|
|
878
|
+
The file is read by what it holds, not its name. `-` reads stdin:
|
|
879
|
+
`pbpaste | forge card - --svg | pbcopy`. `--title` sets the card's heading.
|
|
880
|
+
If any line is not a colour, no card is drawn and every such line is named
|
|
881
|
+
(exit 1), so a card never lands in Figma with colours missing.
|
|
869
882
|
- **`--svg`** prints a card of swatches. Pipe it to `pbcopy` and press ⌘V in
|
|
870
883
|
Figma to get real shapes and text layers: `forge scale 6579FD --svg | pbcopy`.
|
|
884
|
+
Each swatch is its own layer, named after its colour.
|
|
871
885
|
- **`--json`** returns `palette` (`source`, `colours[]` with `hex`, `rgb`,
|
|
872
|
-
`oklch`, `share`)
|
|
873
|
-
`oklch`, `white`, `black`)
|
|
886
|
+
`oklch`, `share`), `scale` (`reference`, `steps[]` with `step`, `hex`,
|
|
887
|
+
`oklch`, `white`, `black`) or `card` (`source`, `colours[]` with `name`,
|
|
888
|
+
`hex`, and `alpha` when a colour is see-through).
|
|
874
889
|
|
|
875
890
|
On a colour terminal each row starts with a swatch. Piped, or under
|
|
876
891
|
`NO_COLOR`, the rows are plain text.
|
|
@@ -1069,7 +1084,7 @@ Claude Desktop and Cursor:
|
|
|
1069
1084
|
{ "mcpServers": { "forge": { "command": "forge", "args": ["mcp"] } } }
|
|
1070
1085
|
```
|
|
1071
1086
|
|
|
1072
|
-
|
|
1087
|
+
Nine tools, deliberately few:
|
|
1073
1088
|
|
|
1074
1089
|
| Tool | Does |
|
|
1075
1090
|
| --- | --- |
|
|
@@ -1078,8 +1093,10 @@ Seven tools, deliberately few:
|
|
|
1078
1093
|
| `forge_convert` | convert to a target format (`quality`, `dpi`, `pages`, `background`, `password`, `overwrite`; images also `trim`, `crop`, `resize`, `sharpen`, `boost: 2 \| 3 \| 4` and `removeBackground`, the last two needing the optional extensions) |
|
|
1079
1094
|
| `forge_compress` | compress by `quality` or to a `maxSize` (also `dpi` for PDFs, `output`, `overwrite`; no `password`: compression refuses encrypted PDFs) |
|
|
1080
1095
|
| `forge_pdf` | `merge`, `split`, `extract`, `delete`, `rotate` |
|
|
1096
|
+
| `forge_clip` | the image on the clipboard, compressed (`quality`, `maxSize`) or converted (`to`) and put back; `undo: true` restores the original |
|
|
1081
1097
|
| `forge_palette` | an image's main colours with their shares; `inside` gives one colour's shades (read-only) |
|
|
1082
1098
|
| `forge_scale` | a 50–950 tonal scale with the colour at 500, rated for white and black text; the colour as hex, `rgb()`, `hsl()`, `oklch()` or a name (read-only) |
|
|
1099
|
+
| `forge_card` | named colours (`title`, `colours: [{ name, colour }]`, optional `subtitle` and `theme`) drawn as the SVG swatch card; pipe it to `pbcopy` and paste into Figma for one layer per colour (read-only) |
|
|
1083
1100
|
|
|
1084
1101
|
Paths must be absolute. Results come back as structured content in the
|
|
1085
1102
|
`--json` shape below, with a `file://` link to every output, and never as
|
|
@@ -1119,7 +1136,7 @@ photo.png · PNG · 122 KB · 2756×774
|
|
|
1119
1136
|
With `--json`:
|
|
1120
1137
|
|
|
1121
1138
|
```json
|
|
1122
|
-
{"forge":"0.5.
|
|
1139
|
+
{"forge":"0.5.6","ok":true,"probes":[{"path":"/Users/me/photo.png","kind":"image","format":"png","bytes":122449,"width":2756,"height":774,"targets":["jpeg","png","webp","avif","gif","tiff","pdf"],"actions":["convert"]}],"failures":[]}
|
|
1123
1140
|
```
|
|
1124
1141
|
|
|
1125
1142
|
`targets` and `actions` come from the engines' own capabilities, so they are
|
|
@@ -1145,7 +1162,7 @@ succeeded) and `failures`. A conversion, compression or page operation adds
|
|
|
1145
1162
|
|
|
1146
1163
|
```jsonc
|
|
1147
1164
|
{
|
|
1148
|
-
"forge": "0.5.
|
|
1165
|
+
"forge": "0.5.6",
|
|
1149
1166
|
"ok": false,
|
|
1150
1167
|
"results": [
|
|
1151
1168
|
{
|
|
@@ -1170,7 +1187,8 @@ succeeded) and `failures`. A conversion, compression or page operation adds
|
|
|
1170
1187
|
|
|
1171
1188
|
`--formats --json` returns `formats` (`id`, `label`, `extensions`, `read`,
|
|
1172
1189
|
`write`, `lossy`). `forge probe --json` returns `probes`. `forge palette
|
|
1173
|
-
--json` returns `palette`,
|
|
1190
|
+
--json` returns `palette`, `forge scale --json` returns `scale`, and `forge
|
|
1191
|
+
card --json` returns `card` (see
|
|
1174
1192
|
[Colour](#colour)). `forge config
|
|
1175
1193
|
--json` returns `config` and `warnings`. An argument error is a document with
|
|
1176
1194
|
one `invalid-arguments` failure and exit code 2. Fields are not renamed or
|
|
@@ -1479,7 +1497,7 @@ src/
|
|
|
1479
1497
|
│ └── report.ts stdout formatting (success, batch, errors, --formats)
|
|
1480
1498
|
│
|
|
1481
1499
|
├── mcp/ the MCP server — a third front end, loaded only by `forge mcp`
|
|
1482
|
-
│ ├── server.ts createForgeServer():
|
|
1500
|
+
│ ├── server.ts createForgeServer(): nine tools; runMcpServer(): stdio
|
|
1483
1501
|
│ ├── tools.ts tool handlers → the same intents and runIntent() the CLI uses
|
|
1484
1502
|
│ ├── schemas.ts zod input/output schemas, vocabularies read from core/actions
|
|
1485
1503
|
│ └── stdout-guard.ts stdout belongs to the protocol; stray writes go to stderr
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
3
|
import"./chunk-TMUK2DD3.js";import{readFile as x}from"node:fs/promises";import{dirname as m,join as u}from"node:path";import{fileURLToPath as C}from"node:url";var c=[{name:"sharp \xB7 libvips",licence:"Apache-2.0 \xB7 LGPL-3.0",does:"images",packages:["sharp"]},{name:"PDFium",licence:"BSD-3-Clause",does:"PDF pages",packages:[]},{name:"pdf-lib",licence:"MIT",does:"writing PDFs",packages:["pdf-lib"]},{name:"mammoth \xB7 docx",licence:"BSD-2-Clause \xB7 MIT",does:"Word documents",packages:["mammoth","docx"]},{name:"Ink \xB7 React",licence:"MIT",does:"this screen",packages:["ink","react"]}],g=[{name:"@hyzyla/pdfium",licence:"MIT"}],h=[{name:"Noto Sans",licence:"OFL-1.1"},{name:"xkcd colour survey",licence:"CC0-1.0"}];function l(n){let t=[];for(let e of n.split(`
|
|
4
|
-
`)){let i=/^((?:@[^/\s]+\/)?[^@\s]+)@\S+ — (.+)$/.exec(e);i&&t.push({name:i[1],licence:i[2].replace(/^\((.*)\)$/,"$1")})}return t}var d=n=>n.name.replace(/^@/,"");function p({bundled:n,extensions:t}){let e=new Set(c.flatMap(s=>s.packages)),i=[...n.filter(s=>!e.has(s.name)),...g,...h].sort((s,r)=>d(s).localeCompare(d(r)));return[{title:"App",credits:c.map(({packages:s,...r})=>r)},...t.length>0?[{title:"Extensions",credits:t}]:[],{title:"Others",credits:i}]}var f="third-party-licenses.txt";function y(n){let t=[],e=m(n);for(let i=0;i<4;i++)t.push(u(e,f),u(e,"dist",f)),e=m(e);return t}async function k(n){for(let t of y(C(n))){let e=await x(t,"utf8").catch(()=>{});if(e!==void 0)return{path:t,text:e}}}async function F({from:n=import.meta.url,list:t=async()=>(await import("./manager-
|
|
4
|
+
`)){let i=/^((?:@[^/\s]+\/)?[^@\s]+)@\S+ — (.+)$/.exec(e);i&&t.push({name:i[1],licence:i[2].replace(/^\((.*)\)$/,"$1")})}return t}var d=n=>n.name.replace(/^@/,"");function p({bundled:n,extensions:t}){let e=new Set(c.flatMap(s=>s.packages)),i=[...n.filter(s=>!e.has(s.name)),...g,...h].sort((s,r)=>d(s).localeCompare(d(r)));return[{title:"App",credits:c.map(({packages:s,...r})=>r)},...t.length>0?[{title:"Extensions",credits:t}]:[],{title:"Others",credits:i}]}var f="third-party-licenses.txt";function y(n){let t=[],e=m(n);for(let i=0;i<4;i++)t.push(u(e,f),u(e,"dist",f)),e=m(e);return t}async function k(n){for(let t of y(C(n))){let e=await x(t,"utf8").catch(()=>{});if(e!==void 0)return{path:t,text:e}}}async function F({from:n=import.meta.url,list:t=async()=>(await import("./manager-ROCFK7AS.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-QQT6OD7W.js"),r=i.filter(o=>o.installed!==void 0).flatMap(o=>s(o.entry)),a=p({bundled:l(e?.text??""),extensions:r});return e?{sections:a,file:e.path}:{sections:a}}export{F as loadCredits};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f}from"./chunk-2BPH3IL6.js";import"./chunk-WBV6I7UP.js";import"./chunk-LAJAXLGQ.js";import"./chunk-HZDYZ5RD.js";import"./chunk-N32JL4UI.js";import"./chunk-WNYM6NSV.js";import"./chunk-KQ2AHGLK.js";import"./chunk-EEQSUBBL.js";import"./chunk-W43SUVWN.js";import"./chunk-FAUL5L2W.js";import"./chunk-HTA25PO2.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{b as COMMANDS_HELP,a as EXIT_CODES_HELP,d as colourUsage,c as commandsHelp,f as parseArgs,e as wantsJson};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{r as a}from"./chunk-
|
|
3
|
+
import{r as a}from"./chunk-WNYM6NSV.js";import{e as l}from"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";var c={loadPreferences:l,loadShell:()=>import("./launch-ATJNO6ZO.js")};async function f(e=c,n={}){let t=e.loadShell();t.catch(()=>{});let{prefs:o,warning:r}=await e.loadPreferences(),s=a(o.theme),{launchShell:i}=await t;await i({prefs:o,palette:s,...r===void 0?{}:{warning:r},...n})}export{f as bootShell};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
4
|
-
`)}displayWidth(e){return se(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,i){let
|
|
5
|
-
`+" ".repeat(t+l)),
|
|
6
|
-
${
|
|
7
|
-
`)}};var A=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=ae(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new
|
|
3
|
+
import{b as D}from"./chunk-WBV6I7UP.js";import{a as X,b as Q}from"./chunk-HZDYZ5RD.js";import{j as M}from"./chunk-N32JL4UI.js";import{a as K}from"./chunk-WNYM6NSV.js";import{b as J}from"./chunk-EEQSUBBL.js";import{a as W}from"./chunk-HTA25PO2.js";import{a as Y}from"./chunk-KH5DHZ2U.js";import{a as U}from"./chunk-TLHUFIXD.js";import{m as R}from"./chunk-4MJEEEFA.js";import{G as d,J as H}from"./chunk-ZBMJTIYR.js";import{d as L}from"./chunk-J7FLFHQJ.js";import{b as z}from"./chunk-H3DIRJFE.js";var O=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},k=class extends O{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var E=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new k(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function N(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}import{EventEmitter as le}from"node:events";import G from"node:child_process";import C from"node:path";import F from"node:fs";import m from"node:process";import{stripVTControlCharacters as ce}from"node:util";import{stripVTControlCharacters as se}from"node:util";var T=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,r)=>i.name().localeCompare(r.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),r=n.long&&e._findOption(n.long);!i&&!r?t.push(n):n.long&&!r?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(r=>!r.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>N(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[])}),t.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[]),i.get(o).push(r)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function r(h,p){return t.formatItem(h,n,p,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],u=t.commandDescription(e);u.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(u),i),""]));let l=t.visibleArguments(e).map(h=>r(t.styleArgumentTerm(t.argumentTerm(h)),t.styleArgumentDescription(t.argumentDescription(h))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),h=>h.helpGroupHeading??"Options:").forEach((h,p)=>{let x=h.map(_=>r(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));o=o.concat(this.formatItemList(p,x,t))}),t.showGlobalOptions){let h=t.visibleGlobalOptions(e).map(p=>r(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.concat(this.formatItemList("Global Options:",h,t))}return this.groupItems(e.commands,t.visibleCommands(e),h=>h.helpGroup()||"Commands:").forEach((h,p)=>{let x=h.map(_=>r(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));o=o.concat(this.formatItemList(p,x,t))}),o.join(`
|
|
4
|
+
`)}displayWidth(e){return se(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,i){let o=" ".repeat(2);if(!n)return o+e;let u=e.padEnd(t+e.length-i.displayWidth(e)),l=2,a=(this.helpWidth??80)-t-l-2,h;return a<this.minWidthToWrap||i.preformatted(n)?h=n:h=i.boxWrap(n,a).replace(/\n/g,`
|
|
5
|
+
`+" ".repeat(t+l)),o+u+" ".repeat(l)+h.replace(/\n/g,`
|
|
6
|
+
${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,r=[];return n.forEach(o=>{let u=o.match(i);if(u===null){r.push("");return}let l=[u.shift()],c=this.displayWidth(l[0]);u.forEach(a=>{let h=this.displayWidth(a);if(c+h<=t){l.push(a),c+=h;return}r.push(l.join(""));let p=a.trimStart();l=[p],c=this.displayWidth(p)}),r.push(l.join(""))}),r.join(`
|
|
7
|
+
`)}};var A=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=ae(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new k(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Z(this.name().replace(/^no-/,"")):Z(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},V=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let i=this.negativeOptions.get(n).presetArg,r=i!==void 0?i:!1;return t.negate===(r===e)}};function Z(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ae(s){let e,t,n=/^-[^-]$/,i=/^--[^-]/,r=s.split(/[ |,]+/).concat("guard");if(n.test(r[0])&&(e=r.shift()),i.test(r[0])&&(t=r.shift()),!e&&n.test(r[0])&&(e=r.shift()),!e&&i.test(r[0])&&(e=t,t=r.shift()),r[0].startsWith("-")){let o=r[0],u=`option creation failed due to '${o}' in option flags '${s}'`;throw/^-[^-][^-]/.test(o)?new Error(`${u}
|
|
8
8
|
- a short flag is a single dash and a single character
|
|
9
9
|
- either use a single dash and a single character (for a short flag)
|
|
10
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(
|
|
11
|
-
- too many short flags`):i.test(
|
|
10
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(o)?new Error(`${u}
|
|
11
|
+
- too many short flags`):i.test(o)?new Error(`${u}
|
|
12
12
|
- too many long flags`):new Error(`${u}
|
|
13
|
-
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${s}'.`);return{shortFlag:e,longFlag:t}}function ue(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let n=0;n<=s.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=s.length;i++){let
|
|
13
|
+
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${s}'.`);return{shortFlag:e,longFlag:t}}function ue(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let n=0;n<=s.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=s.length;i++){let r;s[i-1]===e[n-1]?r=0:r=1,t[i][n]=Math.min(t[i-1][n]+1,t[i][n-1]+1,t[i-1][n-1]+r),i>1&&n>1&&s[i-1]===e[n-2]&&s[i-2]===e[n-1]&&(t[i][n]=Math.min(t[i][n],t[i-2][n-2]+1))}return t[s.length][e.length]}function q(s,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=s.startsWith("--");t&&(s=s.slice(2),e=e.map(o=>o.slice(2)));let n=[],i=3,r=.4;return e.forEach(o=>{if(o.length<=1)return;let u=ue(s,o),l=Math.max(s.length,o.length);(l-u)/l>r&&(u<i?(i=u,n=[o]):u===i&&n.push(o))}),n.sort((o,u)=>o.localeCompare(u)),t&&(n=n.map(o=>`--${o}`)),n.length>1?`
|
|
14
14
|
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
15
|
-
(Did you mean ${n[0]}?)`:""}var $=class s extends le{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>m.stdout.write(t),writeErr:t=>m.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>m.stdout.isTTY?m.stdout.columns:void 0,getErrHelpWidth:()=>m.stderr.isTTY?m.stderr.columns:void 0,getOutHasColors:()=>te()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>te()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:t=>
|
|
16
|
-
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new E(e,t)}argument(e,t,n,i){let
|
|
17
|
-
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new
|
|
18
|
-
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),
|
|
19
|
-
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(F.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",
|
|
15
|
+
(Did you mean ${n[0]}?)`:""}var $=class s extends le{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>m.stdout.write(t),writeErr:t=>m.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>m.stdout.isTTY?m.stdout.columns:void 0,getErrHelpWidth:()=>m.stderr.isTTY?m.stderr.columns:void 0,getOutHasColors:()=>te()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>te()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:t=>ce(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let i=t,r=n;typeof i=="object"&&i!==null&&(r=i,i=null),r=r||{};let[,o,u]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return i&&(l.description(i),l._executableHandler=!0),r.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(r.noHelp||r.hidden),l._executableFile=r.executableFile||null,u&&l.arguments(u),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),i?this:l}createCommand(e){return new s(e)}createHelp(){return Object.assign(new T,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
16
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new E(e,t)}argument(e,t,n,i){let r=this.createArgument(e,t);return typeof n=="function"?r.default(i).argParser(n):r.default(n),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,i,r]=n.match(/([^ ]+) *(.*)/),o=t??"display help for command",u=this.createCommand(i);return u.helpOption(!1),r&&u.arguments(r),o&&u.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=u,(e||t)&&this._initCommandGroup(u),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
17
|
+
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new O(e,t,n)),m.exit(e)}action(e){let t=n=>{let i=this.registeredArguments.length,r=n.slice(0,i);return this._storeOptionsAsProperties?r[i]=this:r[i]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new A(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${i} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
18
|
+
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(r,o,u)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let l=this.getOptionValue(n);r!==null&&e.parseArg?r=this._callParseArg(e,r,l,o):r!==null&&e.variadic&&(r=e._collectValue(r,l)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(n,r,u)};return this.on("option:"+t,r=>{let o=`error: option '${e.flags}' argument '${r}' is invalid.`;i(r,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let o=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;i(r,o,"env")}),this}_optionEx(e,t,n,i,r){if(typeof t=="object"&&t instanceof A)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,n);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(r).argParser(i);else if(i instanceof RegExp){let u=i;i=(l,c)=>{let a=u.exec(l);return a?a[0]:c},o.default(r).argParser(i)}else o.default(i);return this.addOption(o)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){m.versions?.electron&&(t.from="electron");let i=m.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=m.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":m.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?(this.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,"default")}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
19
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(F.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",r=`'${e}' does not exist
|
|
20
20
|
- if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
21
21
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
22
|
-
- ${i}`;throw new Error(
|
|
22
|
+
- ${i}`;throw new Error(r)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function i(a,h){let p=C.resolve(a,h);if(F.existsSync(p))return p;if(n.includes(C.extname(h)))return;let x=n.find(_=>F.existsSync(`${p}${_}`));if(x)return`${p}${x}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=e._executableFile||`${this._name}-${e._name}`,o=this._executableDir||"";if(this._scriptPath){let a;try{a=F.realpathSync(this._scriptPath)}catch{a=this._scriptPath}o=C.resolve(C.dirname(a),o)}if(o){let a=i(o,r);if(!a&&!e._executableFile&&this._scriptPath){let h=C.basename(this._scriptPath,C.extname(this._scriptPath));h!==this._name&&(a=i(o,`${h}-${e._name}`))}r=a||r}let u=n.includes(C.extname(r)),l;m.platform!=="win32"?u?(t.unshift(r),t=ee(m.execArgv).concat(t),l=G.spawn(m.argv[0],t,{stdio:"inherit"})):l=G.spawn(r,t,{stdio:"inherit"}):(this._checkForMissingExecutable(r,o,e._name),t.unshift(r),t=ee(m.execArgv).concat(t),l=G.spawn(m.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{m.on(h,()=>{l.killed===!1&&l.exitCode===null&&l.kill(h)})});let c=this._exitCallback;l.on("close",a=>{a=a??1,c?c(new O(a,"commander.executeSubCommandAsync","(close)")):m.exit(a)}),l.on("error",a=>{if(a.code==="ENOENT")this._checkForMissingExecutable(r,o,e._name);else if(a.code==="EACCES")throw new Error(`'${r}' not executable`);if(!c)m.exit(1);else{let h=new O(1,"commander.executeSubCommandAsync","(error)");h.nestedError=a,c(h)}}),this.runningCommand=l}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let r;return r=this._chainOrCallSubCommandHook(r,i,"preSubcommand"),r=this._chainOrCall(r,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._parseCommand(t,n)}),r}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,i,r)=>{let o=i;if(i!==null&&n.parseArg){let u=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;o=this._callParseArg(n,i,r,u)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let r=n.defaultValue;n.variadic?i<this.args.length?(r=this.args.slice(i),n.parseArg&&(r=r.reduce((o,u)=>e(n,u,o),n.defaultValue))):r===void 0&&(r=[]):i<this.args.length&&(r=this.args[i],n.parseArg&&(r=e(n,r,n.defaultValue))),t[i]=r}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(o=>{i.push({hookedCommand:r,callback:o})})}),t==="postAction"&&i.reverse(),i.forEach(r=>{n=this._chainOrCall(n,()=>r.callback(r.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(r=>{i=this._chainOrCall(i,()=>r(this,t))}),i}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(r))i(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(r=>n.conflictsWith.includes(r.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t;function r(a){return a.length>1&&a[0]==="-"}let o=a=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(a)?!this._getCommandAndAncestors().some(h=>h.options.map(p=>p.short).some(p=>/^-\d$/.test(p))):!1,u=null,l=null,c=0;for(;c<e.length||l;){let a=l??e[c++];if(l=null,a==="--"){i===n&&i.push(a),i.push(...e.slice(c));break}if(u&&(!r(a)||o(a))){this.emit(`option:${u.name()}`,a);continue}if(u=null,r(a)){let h=this._findOption(a);if(h){if(h.required){let p=e[c++];p===void 0&&this.optionMissingArgument(h),this.emit(`option:${h.name()}`,p)}else if(h.optional){let p=null;c<e.length&&(!r(e[c])||o(e[c]))&&(p=e[c++]),this.emit(`option:${h.name()}`,p)}else this.emit(`option:${h.name()}`);u=h.variadic?h:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let h=this._findOption(`-${a[1]}`);if(h){h.required||h.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${h.name()}`,a.slice(2)):(this.emit(`option:${h.name()}`),l=`-${a.slice(2)}`);continue}}if(/^--[^=]+=/.test(a)){let h=a.indexOf("="),p=this._findOption(a.slice(0,h));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,a.slice(h+1));continue}}if(i===t&&r(a)&&!(this.commands.length===0&&o(a))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(a)){t.push(a),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a,...e.slice(c));break}else if(this._defaultCommandName){n.push(a,...e.slice(c));break}}if(this._passThroughOptions){i.push(a,...e.slice(c));break}i.push(a)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
23
23
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
24
24
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
25
|
-
`),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,
|
|
26
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>N(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=C.basename(e,C.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=t.formatHelp(this,t);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,n,i,
|
|
27
|
-
Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,
|
|
28
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ee(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="9229",
|
|
25
|
+
`),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,r=n.code||"commander.error";this._exit(i,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in m.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,m.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new V(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=o=>{let u=o.attributeName(),l=this.getOptionValue(u),c=this.options.find(h=>h.negate&&u===h.attributeName()),a=this.options.find(h=>!h.negate&&u===h.attributeName());return c&&(c.presetArg===void 0&&l===!1||c.presetArg!==void 0&&l===c.presetArg)?c:a||o},i=o=>{let u=n(o),l=u.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},r=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(u=>u.long).map(u=>u.long);i=i.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);t=q(e,i)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",i=e.length,r=this.parent?` for '${this.name()}'`:"",o=e.join(", "),u=`error: too many arguments${r}. Expected ${t} argument${n} but got ${i}: ${o}.`;this.error(u,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(r=>{i.push(r.name()),r.alias()&&i.push(r.alias())}),t=q(e,i)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
26
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>N(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=C.basename(e,C.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=t.formatHelp(this,t);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,n,i,r;return t?(n=u=>this._outputConfiguration.writeErr(u),i=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(n=u=>this._outputConfiguration.writeOut(u),i=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth()),{error:t,write:u=>(i||(u=this._outputConfiguration.stripColor(u)),n(u)),hasColors:i,helpWidth:r}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let r=this.helpInformation({error:n.error});if(t&&(r=t(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(m.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
27
|
+
Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,r=>{let o;typeof t=="function"?o=t({error:r.error,command:r.command}):o=t,o&&r.write(`${o}
|
|
28
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ee(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],n=r[3],i=r[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}function te(){if(m.env.NO_COLOR||m.env.FORCE_COLOR==="0"||m.env.FORCE_COLOR==="false")return!1;if(m.env.FORCE_COLOR||m.env.CLICOLOR_FORCE!==void 0)return!0}var et=new $;function he(s){let[,e,t,...n]=s;if(e===void 0||e==="list")return{kind:"config",action:"list"};if(e==="path")return{kind:"config",action:"path"};if(e==="set"){if(t===void 0||!W.includes(t))throw d(`Unknown config setting ${t??"(none)"}.`,`Try one of: ${W.join(", ")}.`);let i=n.join(" ");if(i.length===0)throw d(`forge config set ${t} needs a value.`);return{kind:"config",action:"set",key:t,value:i}}throw d(`Unknown config action ${e}.`,"Try: forge config list, forge config set <setting> <value>, or forge config path.")}var de={jpg:"jpeg",tif:"tiff",heif:"heic"};function I(s){let e=s.toLowerCase().replace(/^\./,""),t=z(de[e]??e);if(!t)throw d(`${s} is not a format Forge knows.`,"Run forge --formats to see what is available.");return t.id}function P(s,e,t,n,i){let r=Number(String(e).replace(/k$/i,""));if(!Number.isFinite(r)||r<t||r>n)throw d(`${s} takes ${t} to ${n}, not ${e}.`,`For example ${s} ${i}.`);return r}function pe(s){let e={};if(s.cut!==void 0){let t=J(String(s.cut));if(!t)throw d(`--cut takes a start and an end, the end after the start, not ${s.cut}.`,"For example --cut 0:03.2-0:41, or --cut 0:10- to keep from 0:10 to the end.");e.cut=t.end===void 0?{start:t.start}:{start:t.start,end:t.end}}return s.mute&&(e.mute=!0),s.speed!==void 0&&(e.speed=P("--speed",s.speed,.25,4,"2")),s.fps!==void 0&&(e.fps=P("--fps",s.fps,1,120,"30")),s.bitrate!==void 0&&(e.bitrate=Math.round(P("--bitrate",s.bitrate,32,320,"128k"))),s.loudness!==void 0&&(e.loudness=P("--loudness",s.loudness,-70,-5,"-16")),s.cleanAudio&&(e.cleanup=!0,e.loudness??=-16),Object.keys(e).length?e:void 0}function S(s){let e=Number(s);if(!Number.isInteger(e)||e<1||e>100)throw d(`Quality must be a whole number between 1 and 100, not ${s}.`);return e}function ne(s,e){let t=/^\d+$/.test(String(e))?Number(e):Number.NaN;if(!Number.isInteger(t)||t<1)throw d(`${s} takes a whole number of pixels, at least 1, not ${e}.`);return t}function fe(s){let e=String(s),t=/^\d+(\.\d+)?%?$/.test(e)?Number.parseFloat(e):Number.NaN;if(!(t>=1&&t<=D))throw d(`--resize takes a percent from 1 to ${D}, not ${s}.`,"Try --resize 50% to halve, or --width 1200 for an exact width.");return t}function j(s){let e=Number(s);if(!Number.isInteger(e)||e<1)throw d(`Concurrency must be a positive whole number, not ${s}.`);return e}var me=`
|
|
29
29
|
Exit codes:
|
|
30
30
|
0 every input succeeded
|
|
31
31
|
1 the command was understood, and at least one input failed or was refused
|
|
@@ -34,6 +34,8 @@ Other commands:
|
|
|
34
34
|
forge probe <files...> what each file is and what Forge can do with it
|
|
35
35
|
forge palette <image> an image's main colours (--json, --svg, --inside <hex>)
|
|
36
36
|
forge scale <colour> 50\u2013950 from one colour, with it at 500 (--json, --svg)
|
|
37
|
+
forge card <file> named colours as a card to paste into Figma
|
|
38
|
+
(--svg, --json, --title <text>; - reads stdin)
|
|
37
39
|
forge clip compress the copied image and put it back (--to, --quality,
|
|
38
40
|
--max-size, --save [folder], --undo)
|
|
39
41
|
forge transcribe <file | link>
|
|
@@ -47,17 +49,24 @@ Other commands:
|
|
|
47
49
|
forge extensions [add | remove <id>] optional extras, such as boost and remove-background
|
|
48
50
|
forge update install a newer Forge, if there is one
|
|
49
51
|
forge uninstall take Forge out of the right-click menu, then remove it
|
|
50
|
-
forge mcp run as a local MCP server over stdio, for AI agents`;function ge(s=process.platform){if(s==="darwin")return ie;let e=s==="win32"?"boost and whisper":"whisper and heic";return ie.replace("a video or audio file, or a YouTube link, into notes","a video or audio file, or a YouTube link, into a transcript").replace("optional extras, such as boost and remove-background",`optional extras, such as ${e}`)}function B(s){let e=L(String(s));if(e===void 0)throw d(`${s} is not a size.`,"Try a number with a unit, for example 500kb, 2mb or 1.5mb.");return e}function be(s){let e=s.slice(1).filter(n=>n!=="--json"),t=e.find(n=>n.startsWith("-"));if(t!==void 0)throw d(`forge probe takes files, not ${t}.`,"Try: forge probe photo.jpg --json");if(e.length===0)throw d("No files given.","Name a file, for example: forge probe scan.pdf --json");return{kind:"probe",inputs:e}}function _e(s){let e={kind:"clip",undo:!1,debug:!1},t=s.slice(1),n=(i,
|
|
52
|
+
forge mcp run as a local MCP server over stdio, for AI agents`;function ge(s=process.platform){if(s==="darwin")return ie;let e=s==="win32"?"boost and whisper":"whisper and heic";return ie.replace("a video or audio file, or a YouTube link, into notes","a video or audio file, or a YouTube link, into a transcript").replace("optional extras, such as boost and remove-background",`optional extras, such as ${e}`)}function B(s){let e=L(String(s));if(e===void 0)throw d(`${s} is not a size.`,"Try a number with a unit, for example 500kb, 2mb or 1.5mb.");return e}function be(s){let e=s.slice(1).filter(n=>n!=="--json"),t=e.find(n=>n.startsWith("-"));if(t!==void 0)throw d(`forge probe takes files, not ${t}.`,"Try: forge probe photo.jpg --json");if(e.length===0)throw d("No files given.","Name a file, for example: forge probe scan.pdf --json");return{kind:"probe",inputs:e}}function _e(s){let e={kind:"clip",undo:!1,debug:!1},t=s.slice(1),n=(i,r)=>{let o=t[r+1];if(o===void 0||o.startsWith("-"))throw d(`${i} needs a value.`);return o};for(let i=0;i<t.length;i++){let r=t[i];if(r!=="--json")if(r==="--debug")e.debug=!0;else if(r==="--undo")e.undo=!0;else if(r==="--to"||r==="-t")e.target=I(n(r,i++));else if(r==="--quality"||r==="-q")e.quality=S(n(r,i++));else if(r==="--max-size")e.maxBytes=B(n(r,i++));else if(r==="--save"){let o=t[i+1];e.save=o===void 0||o.startsWith("-")?!0:t[++i]}else throw r.startsWith("-")?d(`forge clip does not take ${r}.`,"Try: forge --help"):d(`forge clip takes no files: it reads the clipboard, not ${r}.`,`To compress a file, try: forge ${r} --quality 80`)}if(e.undo&&Object.keys(e).some(i=>!["kind","undo","debug"].includes(i)))throw d("--undo takes no other flag.","Try: forge clip --undo");if(e.quality!==void 0&&e.maxBytes!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");return e}function we(s){let e=s.slice(1),t=[],n={kind:"transcribe",input:"",notes:!0,transcript:!0,detail:Q,force:!1,debug:!1},i=(l,c)=>{let a=e[c+1];if(a===void 0||a.startsWith("-"))throw d(`${l} needs a value.`);return a},r="Try: forge transcribe talk.mp4";for(let l=0;l<e.length;l++){let c=e[l];if(c==="--debug")n.debug=!0;else if(c==="--force"||c==="-f")n.force=!0;else if(c==="--language"||c==="-l")n.language=i(c,l++);else if(c==="--output"||c==="-o")n.output=i(c,l++);else if(c==="--detail"){let a=i(c,l++).toLowerCase();if(!X.includes(a))throw d(`forge transcribe writes notes in brief, standard or detailed, not ${a}.`,"Try: forge transcribe talk.mp4 --detail brief");n.detail=a}else if(c==="--format"){let a=i(c,l++).toLowerCase(),h=Y.find(p=>p.id===a||p.label.toLowerCase()===a);if(h===void 0)throw d(`forge transcribe writes md, docx, pdf or txt, not ${a}.`,"Try: forge transcribe talk.mp4 --format pdf");n.format=h.id}else if(c==="--to"||c==="-t"){let a=i(c,l++).toLowerCase();if(a!=="all"&&a!=="notes"&&a!=="transcript")throw d(`forge transcribe makes all, notes or a transcript, not ${a}.`,"Try: forge transcribe talk.mp4 --to transcript");n.to=a,n.notes=a!=="transcript",n.transcript=a!=="notes"}else{if(c.startsWith("-"))throw d(`forge transcribe does not take ${c}.`,r);t.push(c)}}let[o,...u]=t;if(o===void 0)throw d("forge transcribe needs a file or a link.",r);if(u.length>0)throw d("forge transcribe takes one file or link at a time.",r);return{...n,input:o}}function ye(s){let e=s.slice(1),t=[],n,i={kind:"watch",newOnly:!1,debug:!1},r={},o=(c,a)=>{let h=e[a+1];if(h===void 0||h.startsWith("-"))throw d(`${c} needs a value.`);return h};for(let c=0;c<e.length;c++){let a=e[c];if(a!=="--json")if(a==="--debug")i.debug=!0;else if(a==="--new-only")i.newOnly=!0;else if(a==="--to"||a==="-t")n=I(o(a,c++));else if(a==="--quality"||a==="-q")r.quality=S(o(a,c++));else if(a==="--output"||a==="-o")r.output=o(a,c++);else if(a==="--dpi"){let h=o(a,c++),p=Number(h);if(!Number.isInteger(p)||p<36||p>600)throw H(h);r.dpi=p}else{if(a.startsWith("-"))throw d(`forge watch does not take ${a}.`,"Try: forge watch ./images --to webp");t.push(a)}}let[u,...l]=t;if(u===void 0)throw d("forge watch needs a folder.","Try: forge watch ./images --to webp");if(l.length>0)throw d("forge watch watches one folder at a time.",`Try: forge watch ${u} --to webp`);if(n===void 0)throw d("forge watch needs a format to convert to.",`Try: forge watch ${u} --to webp`);return{kind:"watch",folder:u,target:n,...r.quality===void 0?{}:{quality:r.quality},...r.dpi===void 0?{}:{dpi:r.dpi},...r.output===void 0?{}:{output:r.output},newOnly:i.newOnly,debug:i.debug}}function xe(s){let e=s.slice(1).filter(o=>o!=="--json"),t=e.find(o=>o.startsWith("-"));if(t!==void 0)throw d(`forge extensions does not take ${t}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");let[n,i,...r]=e;if(n===void 0)return{kind:"extensions",action:"list"};if(n!=="add"&&n!=="remove")throw d(`Unknown extensions action ${n}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");if(i===void 0||r.length>0)throw d(`forge extensions ${n} takes exactly one extension.`,`Try: forge extensions ${n} boost`);return{kind:"extensions",action:n,id:i}}function re(s){if(s===void 0)throw d("No colour given.","Try: forge scale 6579FD \u2014 or quote it, '#6579FD', because an unquoted # starts a comment in the shell.");let e=M(s)?.rgb;if(!e)throw d(`${s} is not a colour.`,"Try a hex code (6579FD), rgb(), hsl(), oklch() or a colour name, quoted: 'rgb(101 121 253)'.");return e}function Oe(s,e=process.platform,t=process.env){let r=e==="linux"&&!t.WAYLAND_DISPLAY&&!!t.DISPLAY?" --svg a card of swatches; pipe to xclip -sel c, paste into Figma":` --svg a card of swatches; pipe to ${e==="win32"?"clip":e==="linux"?"wl-copy":"pbcopy"} and paste into Figma`;return s==="card"?`Usage: forge card <file> [--json] [--svg] [--title <text>]
|
|
53
|
+
|
|
54
|
+
Named colours from design tokens, a CSV, CSS variables or one a line
|
|
55
|
+
(bg #F8F1E6). - reads them from stdin.
|
|
56
|
+
--json one JSON document: card.colours[] with name and hex
|
|
57
|
+
${r}
|
|
58
|
+
--title <text> the card's heading; the file's name if not given
|
|
59
|
+
`:s==="scale"?`Usage: forge scale <colour> [--json] [--svg]
|
|
51
60
|
|
|
52
61
|
50\u2013950 built in OKLCH, with <colour> at 500. Pass the hex without #, or quote it.
|
|
53
62
|
--json one JSON document: scale.steps[] with hex, oklch, white, black
|
|
54
|
-
${
|
|
63
|
+
${r}
|
|
55
64
|
`:`Usage: forge palette <image> [--json] [--svg] [--inside <hex>]
|
|
56
65
|
|
|
57
66
|
An image's main colours, most of the image first.
|
|
58
67
|
--json one JSON document: palette.colours[] with hex, rgb, oklch, share
|
|
59
|
-
${
|
|
68
|
+
${r}
|
|
60
69
|
--inside <hex> the shades of the palette colour nearest <hex>
|
|
61
|
-
`}function Ce(s){let[e,...t]=s;if(t.includes("--help")||t.includes("-h"))throw process.stdout.write(
|
|
62
|
-
${me}`).configureOutput({outputError:()=>{}}).exitOverride().allowExcessArguments(!1);try{t.parse(s,{from:"user"})}catch(f){if(f instanceof
|
|
63
|
-
`),w=b.join(" ").trim().replace(/^\((.*)\)\.?$/,"$1");throw d(`${g.charAt(0).toUpperCase()}${g.slice(1).replace(/\.$/,"")}.`,w||"Run forge --help to see what Forge accepts.")}throw f}let n=t.opts(),i=t.args;if(n.formats)return{kind:"formats"};let
|
|
70
|
+
`}function Ce(s){let[e,...t]=s;if(t.includes("--help")||t.includes("-h"))throw process.stdout.write(Oe(e==="scale"?"scale":e==="card"?"card":"palette")),new O(0,"commander.helpDisplayed","(outputHelp)");if(e==="card")return ve(t);let n=t.filter(l=>l!=="--json"&&l!=="--svg"),i=t.includes("--svg"),r=n.indexOf("--inside"),o=r===-1?void 0:n[r+1];r!==-1&&n.splice(r,2);let u=n.find(l=>l.startsWith("-"));if(u!==void 0)throw d(`forge ${e} does not take ${u}.`,`Try: forge ${e} --help`);if(e==="scale"){if(r!==-1)throw d("--inside is for forge palette.","Try: forge palette photo.jpg --inside F26E69");if(n.length>1)throw d("forge scale takes one colour.","Try: forge scale 6579FD");return{kind:"scale",colour:re(n[0]),svg:i}}if(n.length!==1)throw d(n.length===0?"No image given.":"forge palette takes one image.","Try: forge palette photo.jpg");return{kind:"palette",input:n[0],svg:i,...r===-1?{}:{inside:re(o)}}}function ve(s){let e=s.filter(o=>o!=="--json"&&o!=="--svg"),t=s.includes("--svg"),n=e.indexOf("--title"),i=n===-1?void 0:e[n+1];if(n!==-1){if(i===void 0||i.trim()==="")throw d("--title needs the heading.","Try: forge card palette.csv --title 'Cream blue'");e.splice(n,2)}let r=e.find(o=>o.startsWith("-")&&o!=="-");if(r!==void 0)throw d(`forge card does not take ${r}.`,"Try: forge card --help");if(e.length!==1)throw d(e.length===0?"No file given.":"forge card takes one file.","Try: forge card palette.csv --svg");return{kind:"card",input:e[0],svg:t,...i===void 0?{}:{title:i}}}function mt(s){let e=s.indexOf("--");return(e===-1?s:s.slice(0,e)).includes("--json")}function ke(s){let e=s.indexOf("--"),t=e===-1?s:s.slice(0,e),n=e===-1?[]:s.slice(e),i=[],r;for(let o=0;o<t.length;o++){let u=t[o],l=u.startsWith("--boost=")?u.slice(8):void 0;if(u!=="--boost"&&l===void 0){i.push(u);continue}let c=l;if(c===void 0&&/^\d+$/.test(t[o+1]??"")&&(c=t[++o]),c!==void 0&&c!=="2"&&c!=="3"&&c!=="4")throw d(`--boost takes 2, 3 or 4, not ${c}.`,"Try --boost, --boost 2, --boost 3 or --boost 4.");r=c==="4"?4:c==="3"?3:2}return{rest:[...i,...n],...r===void 0?{}:{scale:r}}}function gt(s){let e=s;if(e[0]==="clip"||e[0]==="watch"||e[0]==="transcribe"||e[0]==="config"||e[0]==="probe"||e[0]==="extensions"||e[0]==="palette"||e[0]==="scale"||e[0]==="card"||e[0]==="update"||e[0]==="uninstall")return Ae(e);let t=ke(e);return $e(t.rest,t.scale)}function Ae(s){if(s[0]==="update"){let e=s.slice(1).filter(t=>t!=="--json");if(e.length>0)throw d(`forge update takes nothing else, got: ${e.join(" ")}.`,"Try: forge update");return{kind:"update"}}if(s[0]==="uninstall"){let e=s.slice(1);if(e.length>0)throw d(`forge uninstall takes nothing else, got: ${e.join(" ")}.`,"Try: forge uninstall");return{kind:"uninstall"}}return s[0]==="clip"?_e(s):s[0]==="watch"?ye(s):s[0]==="transcribe"?we(s):s[0]==="config"?he(s.filter(e=>e!=="--json")):s[0]==="probe"?be(s):s[0]==="palette"||s[0]==="scale"||s[0]==="card"?Ce(s):xe(s)}function $e(s,e){let t=new $().name("forge").description("Convert \u2014 transform your files from the terminal").argument("[inputs...]","files, folders or globs").option("-t, --to <format>","target format").option("-o, --output <path>","output file or directory").option("-q, --quality <n>","quality for lossy formats, 1-100").option("--background <colour>","fill colour when flattening transparency","#ffffff").option("--keep-metadata","preserve EXIF and GPS data",!1).option("--recursive","descend into subfolders",!1).option("--force","allow overwriting existing files",!1).option("--max-size <size>","compress until the file fits, e.g. 500kb").option("--concurrency <n>","how many files to convert at once").option("--debug","show underlying errors",!1).option("--formats","list supported formats",!1).option("--merge","combine several PDFs into one").option("--split <mode>","every-page | every=N | at=N,N").option("--extract <pages>","keep only these pages, e.g. 3-7,12").option("--delete <pages>","drop these pages").option("--rotate <degrees>","90, 180 or 270").option("--separate","with --extract, write one file per page").option("--sharpen","sharpen at the same size; needs the boost extension").option("--boost [2|3|4]","sharpen and enlarge 2x (default), 3x or 4x; needs the boost extension").option("--trim","cut transparent or solid-colour edges; keeps the format").option("--crop <W:H>","cut to a shape, e.g. 1:1, 4:5, 16:9; keeps the subject").option("--resize <percent>","resize to a percent of the size, 1-200, e.g. 50%").option("--width <px>","resize to this width; the height follows").option("--height <px>","resize to this height; the width follows").option("--remove-bg","cut out the subject; needs the remove-background extension").option("--cut <start-end>","video or audio: keep from start to end, e.g. 0:03.2-0:41").option("--mute","video: take the sound out").option("--speed <x>","video or audio: play faster or slower, 0.25-4").option("--fps <n>","video: frames per second").option("--bitrate <kbps>","audio: bitrate, e.g. 128k").option("--loudness <LUFS>","audio: even out loudness to this level, e.g. -16").option("--clean-audio","video or audio: take out rumble and hiss, then even the level").option("--preset <name>","run a preset saved from Done, e.g. --preset blog").option("--pages <ranges>","with --to, which pages to render, e.g. 3-7,12").option("--dpi <n>","rasterisation resolution, 36-600","150").option("--password-stdin","read an encrypted PDF's password from stdin").option("--json","print one JSON document on stdout instead of text").helpOption("-h, --help","show this help").version(K,"-V, --version","show the version").addHelpText("after",`${ge()}
|
|
71
|
+
${me}`).configureOutput({outputError:()=>{}}).exitOverride().allowExcessArguments(!1);try{t.parse(s,{from:"user"})}catch(f){if(f instanceof O&&f.code!=="commander.helpDisplayed"&&f.code!=="commander.version"){let[g="",...b]=f.message.replace(/^error: /,"").split(`
|
|
72
|
+
`),w=b.join(" ").trim().replace(/^\((.*)\)\.?$/,"$1");throw d(`${g.charAt(0).toUpperCase()}${g.slice(1).replace(/\.$/,"")}.`,w||"Run forge --help to see what Forge accepts.")}throw f}let n=t.opts(),i=t.args;if(n.formats)return{kind:"formats"};let r=pe(n);if(r!==void 0&&n.trim)throw d("--trim cuts the empty edges of an image.","To keep part of a video or audio file, use --cut, for example --cut 0:03-0:41.");if(n.preset!==void 0){let f=[["to","--to"],["quality","--quality"],["maxSize","--max-size"],["merge","--merge"],["split","--split"],["extract","--extract"],["delete","--delete"],["rotate","--rotate"],["sharpen","--sharpen"],["trim","--trim"],["crop","--crop"],["resize","--resize"],["width","--width"],["height","--height"],["removeBg","--remove-bg"],["pages","--pages"]].filter(([g])=>n[g]!==void 0&&n[g]!==!1).map(([,g])=>g);if(e!==void 0&&f.push("--boost"),f.length>0)throw d(`--preset already says what to do \u2014 leave out ${f.join(" and ")}.`,"Run the preset alone, or change it from Done with \u2192 continue editing.");return{kind:"preset",inputs:i,name:String(n.preset),...n.output===void 0?{}:{output:String(n.output)},force:n.force===!0,recursive:n.recursive===!0,debug:n.debug===!0}}if(n.pages!==void 0&&n.to===void 0)throw d("--pages needs --to: it chooses which pages to render.");let o=["merge","split","extract","delete","rotate"].filter(f=>n[f]!==void 0);if(o.length>1)throw d(`Use one operation at a time \u2014 got ${o.map(f=>`--${f}`).join(" and ")}.`);let u=[...n.sharpen?["--sharpen"]:[],...e!==void 0?["--boost"]:[],...n.removeBg?["--remove-bg"]:[]],l=[...n.resize!==void 0?["--resize"]:[],...n.width!==void 0?["--width"]:[],...n.height!==void 0?["--height"]:[]],c=r!==void 0&&!n.to&&n.quality===void 0&&n.maxSize===void 0;if(n.trim||n.crop!==void 0||l.length>0||c){if(l.length>1)throw d(`Use one of --resize, --width and --height \u2014 got ${l.join(" and ")}.`);let f=n.crop!==void 0?"--crop":l[0]??(n.trim?"--trim":"--cut"),g=[...n.crop!==void 0&&n.trim?["--trim"]:[],...u,...n.maxSize!==void 0?["--max-size"]:[],...n.pages!==void 0?["--pages"]:[],...o.map(oe=>`--${oe}`)][0];if(g!==void 0)throw d(`${f} cannot be combined with ${g}.`,g!=="--max-size"?"Run them one after the other.":f==="--crop"?"Crop first, then compress the result: forge photo-cropped-1x1.jpg --max-size 500kb":"Resize first, then compress the result: forge photo-1200x900.jpg --max-size 500kb");let b=n.crop!==void 0?{aspect:R(String(n.crop))}:void 0,w=n.resize!==void 0?{percent:fe(n.resize)}:n.width!==void 0?{width:ne("--width",n.width)}:n.height!==void 0?{height:ne("--height",n.height)}:void 0;if(i.length===0)throw d("No files given.","Name an image, for example: forge photo.jpg --resize 50%");let v={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(v.quality=S(String(n.quality)));let y={kind:"edit",inputs:i,trim:!!n.trim,options:v,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return b!==void 0&&(y.crop=b),w!==void 0&&(y.resize=w),r!==void 0&&(y.media=r),n.to&&(y.target=I(String(n.to))),n.output!==void 0&&(y.output=String(n.output)),n.concurrency!==void 0&&(y.concurrency=j(String(n.concurrency))),y}let a=n.sharpen?1:e,h=a!==void 0?"boost":n.removeBg?"remove-background":null;if(h!==null){if(u.length>1)throw d(`Use one operation at a time \u2014 got ${u.join(" and ")}.`);let f=u[0];if(o.length>0)throw d(`${f} cannot be combined with --${o[0]}.`);if(n.maxSize!==void 0||n.pages!==void 0)throw d(`${f} cannot be combined with ${n.maxSize!==void 0?"--max-size":"--pages"}.`);if(i.length===0)throw d("No files given.",`Name an image, for example: forge photo.jpg ${f}`);let g=n.to?I(String(n.to)):"png";if(h==="remove-background"){let v=U(g);if(v)throw v}let b={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(b.quality=S(String(n.quality)));let w={kind:"extension-op",op:h,inputs:i,target:g,options:b,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return a!==void 0&&(w.scale=a),n.output!==void 0&&(w.output=String(n.output)),n.concurrency!==void 0&&(w.concurrency=j(String(n.concurrency))),w}if(o.length===1){let f=o[0];if(i.length===0)throw d("No files given.",`Name a PDF, for example: forge doc.pdf --${f}`);if(n.separate&&f!=="extract")throw d(`--separate only applies to --extract, not --${f}.`);if(n.output!==void 0)throw d(`--output does not apply to --${f}.`,"Page operations name their own outputs, beside the source. Rename the result afterwards.");let g={kind:"pageop",action:f,inputs:i,force:!!n.force,debug:!!n.debug};if(f==="rotate"){let b=Number(n.rotate);if(!Number.isInteger(b)||b%90!==0||b===0||b>=360)throw d(`--rotate takes a multiple of 90 below 360, not "${n.rotate}".`);g.rotate=b}if((f==="extract"||f==="delete")&&(g.pages=String(n[f]),f==="extract"&&n.separate&&(g.separate=!0)),f==="split"){let b=String(n.split),w=b.match(/^every=(\d+)$/),v=b.match(/^at=([\d,\s]+)$/);if(b==="every-page")g.split={mode:"every-page"};else if(w?.[1]!==void 0){let y=Number(w[1]);if(!Number.isInteger(y)||y<1)throw d(`--split every=N takes a whole number of pages, at least 1, not "${w[1]}".`);g.split={mode:"every-n",n:y}}else if(v?.[1])g.split={mode:"points",after:v[1].split(",").map(y=>Number(y.trim()))};else throw d(`--split takes every-page, every=N or at=N,N \u2014 not "${b}".`)}return g}if(i.length===0&&!n.to&&n.quality===void 0&&n.maxSize===void 0)return{kind:"shell"};if(n.quality!==void 0&&n.maxSize!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");if(!n.to&&(n.quality!==void 0||n.maxSize!==void 0)){if(i.length===0)throw d("No files given.","Name a file, for example: forge photo.jpg --max-size 500kb");let f={background:String(n.background),keepMetadata:!!n.keepMetadata};r!==void 0&&(f.media=r);let g={kind:"compress",inputs:i,options:f,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};if(n.quality!==void 0&&(g.quality=S(String(n.quality))),n.maxSize!==void 0&&(g.maxBytes=B(n.maxSize)),n.output!==void 0&&(g.output=String(n.output)),t.getOptionValueSource("dpi")==="cli"){let b=Number(n.dpi);if(!Number.isInteger(b)||b<36||b>600)throw H(n.dpi);g.dpi=b}return n.concurrency!==void 0&&(g.concurrency=j(String(n.concurrency))),g}if(!n.to)throw d("No target format given.","Add --to <format>, for example: forge photo.jpg --to webp");if(i.length===0)throw d("No files given.","Name a file, a folder or a glob, for example: forge photo.jpg --to webp");let p={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(p.quality=S(String(n.quality))),r!==void 0&&(p.media=r);let x=Number(n.dpi);if(!Number.isInteger(x)||x<36||x>600)throw H(n.dpi);let _={kind:"convert",inputs:i,target:I(String(n.to)),options:p,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug,dpi:x,passwordStdin:!!n.passwordStdin};return n.output!==void 0&&(_.output=String(n.output)),n.pages!==void 0&&(_.pages=String(n.pages)),n.maxSize!==void 0&&(_.maxBytes=B(n.maxSize)),n.concurrency!==void 0&&(_.concurrency=j(String(n.concurrency))),_}export{me as a,ie as b,ge as c,Oe as d,mt as e,gt as f};
|