shell-dsl 0.0.27 → 0.0.28
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/dist/cjs/index.cjs +24 -13
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/commands/awk/awk.cjs +19 -9
- package/dist/cjs/src/commands/awk/awk.cjs.map +2 -2
- package/dist/cjs/src/commands/break-continue/break-continue.cjs +19 -9
- package/dist/cjs/src/commands/break-continue/break-continue.cjs.map +2 -2
- package/dist/cjs/src/commands/cat/cat.cjs +19 -9
- package/dist/cjs/src/commands/cat/cat.cjs.map +2 -2
- package/dist/cjs/src/commands/cd/cd.cjs +19 -9
- package/dist/cjs/src/commands/cd/cd.cjs.map +2 -2
- package/dist/cjs/src/commands/colon/colon.cjs +19 -9
- package/dist/cjs/src/commands/colon/colon.cjs.map +2 -2
- package/dist/cjs/src/commands/cp/cp.cjs +19 -9
- package/dist/cjs/src/commands/cp/cp.cjs.map +2 -2
- package/dist/cjs/src/commands/cut/cut.cjs +19 -9
- package/dist/cjs/src/commands/cut/cut.cjs.map +2 -2
- package/dist/cjs/src/commands/echo/echo.cjs +19 -9
- package/dist/cjs/src/commands/echo/echo.cjs.map +2 -2
- package/dist/cjs/src/commands/find/find.cjs +19 -9
- package/dist/cjs/src/commands/find/find.cjs.map +2 -2
- package/dist/cjs/src/commands/grep/grep.cjs +19 -9
- package/dist/cjs/src/commands/grep/grep.cjs.map +2 -2
- package/dist/cjs/src/commands/head/head.cjs +19 -9
- package/dist/cjs/src/commands/head/head.cjs.map +2 -2
- package/dist/cjs/src/commands/index.cjs +19 -9
- package/dist/cjs/src/commands/index.cjs.map +2 -2
- package/dist/cjs/src/commands/ls/ls.cjs +19 -9
- package/dist/cjs/src/commands/ls/ls.cjs.map +2 -2
- package/dist/cjs/src/commands/mkdir/mkdir.cjs +19 -9
- package/dist/cjs/src/commands/mkdir/mkdir.cjs.map +2 -2
- package/dist/cjs/src/commands/mv/mv.cjs +19 -9
- package/dist/cjs/src/commands/mv/mv.cjs.map +2 -2
- package/dist/cjs/src/commands/pwd/pwd.cjs +19 -9
- package/dist/cjs/src/commands/pwd/pwd.cjs.map +2 -2
- package/dist/cjs/src/commands/rm/rm.cjs +19 -9
- package/dist/cjs/src/commands/rm/rm.cjs.map +2 -2
- package/dist/cjs/src/commands/sed/sed.cjs +19 -9
- package/dist/cjs/src/commands/sed/sed.cjs.map +2 -2
- package/dist/cjs/src/commands/sort/sort.cjs +19 -9
- package/dist/cjs/src/commands/sort/sort.cjs.map +2 -2
- package/dist/cjs/src/commands/tail/tail.cjs +19 -9
- package/dist/cjs/src/commands/tail/tail.cjs.map +2 -2
- package/dist/cjs/src/commands/tee/tee.cjs +19 -9
- package/dist/cjs/src/commands/tee/tee.cjs.map +2 -2
- package/dist/cjs/src/commands/test/test.cjs +19 -9
- package/dist/cjs/src/commands/test/test.cjs.map +2 -2
- package/dist/cjs/src/commands/touch/touch.cjs +19 -9
- package/dist/cjs/src/commands/touch/touch.cjs.map +2 -2
- package/dist/cjs/src/commands/tr/tr.cjs +19 -9
- package/dist/cjs/src/commands/tr/tr.cjs.map +2 -2
- package/dist/cjs/src/commands/tree/tree.cjs +19 -9
- package/dist/cjs/src/commands/tree/tree.cjs.map +2 -2
- package/dist/cjs/src/commands/true-false/true-false.cjs +19 -9
- package/dist/cjs/src/commands/true-false/true-false.cjs.map +2 -2
- package/dist/cjs/src/commands/uniq/uniq.cjs +19 -9
- package/dist/cjs/src/commands/uniq/uniq.cjs.map +2 -2
- package/dist/cjs/src/commands/wc/wc.cjs +19 -9
- package/dist/cjs/src/commands/wc/wc.cjs.map +2 -2
- package/dist/cjs/src/errors.cjs +19 -9
- package/dist/cjs/src/errors.cjs.map +2 -2
- package/dist/cjs/src/fs/index.cjs +19 -9
- package/dist/cjs/src/fs/index.cjs.map +2 -2
- package/dist/cjs/src/fs/memfs-adapter.cjs +31 -10
- package/dist/cjs/src/fs/memfs-adapter.cjs.map +2 -2
- package/dist/cjs/src/fs/readonly-fs.cjs +19 -9
- package/dist/cjs/src/fs/readonly-fs.cjs.map +2 -2
- package/dist/cjs/src/fs/real-fs.cjs +31 -10
- package/dist/cjs/src/fs/real-fs.cjs.map +2 -2
- package/dist/cjs/src/index.cjs +19 -9
- package/dist/cjs/src/index.cjs.map +2 -2
- package/dist/cjs/src/interpreter/context.cjs +19 -9
- package/dist/cjs/src/interpreter/context.cjs.map +2 -2
- package/dist/cjs/src/interpreter/index.cjs +19 -9
- package/dist/cjs/src/interpreter/index.cjs.map +2 -2
- package/dist/cjs/src/interpreter/interpreter.cjs +19 -9
- package/dist/cjs/src/interpreter/interpreter.cjs.map +2 -2
- package/dist/cjs/src/io/index.cjs +19 -9
- package/dist/cjs/src/io/index.cjs.map +2 -2
- package/dist/cjs/src/io/stdin.cjs +19 -9
- package/dist/cjs/src/io/stdin.cjs.map +2 -2
- package/dist/cjs/src/io/stdout.cjs +19 -9
- package/dist/cjs/src/io/stdout.cjs.map +2 -2
- package/dist/cjs/src/lexer/index.cjs +19 -9
- package/dist/cjs/src/lexer/index.cjs.map +2 -2
- package/dist/cjs/src/lexer/lexer.cjs +19 -9
- package/dist/cjs/src/lexer/lexer.cjs.map +2 -2
- package/dist/cjs/src/lexer/tokens.cjs +19 -9
- package/dist/cjs/src/lexer/tokens.cjs.map +2 -2
- package/dist/cjs/src/parser/ast.cjs +19 -9
- package/dist/cjs/src/parser/ast.cjs.map +2 -2
- package/dist/cjs/src/parser/index.cjs +19 -9
- package/dist/cjs/src/parser/index.cjs.map +2 -2
- package/dist/cjs/src/parser/parser.cjs +19 -9
- package/dist/cjs/src/parser/parser.cjs.map +2 -2
- package/dist/cjs/src/shell-dsl.cjs +19 -9
- package/dist/cjs/src/shell-dsl.cjs.map +2 -2
- package/dist/cjs/src/shell-promise.cjs +19 -9
- package/dist/cjs/src/shell-promise.cjs.map +2 -2
- package/dist/cjs/src/types.cjs +19 -9
- package/dist/cjs/src/types.cjs.map +2 -2
- package/dist/cjs/src/utils/escape.cjs +19 -9
- package/dist/cjs/src/utils/escape.cjs.map +2 -2
- package/dist/cjs/src/utils/expand-escapes.cjs +19 -9
- package/dist/cjs/src/utils/expand-escapes.cjs.map +2 -2
- package/dist/cjs/src/utils/flag-parser.cjs +27 -9
- package/dist/cjs/src/utils/flag-parser.cjs.map +3 -3
- package/dist/cjs/src/utils/index.cjs +19 -9
- package/dist/cjs/src/utils/index.cjs.map +2 -2
- package/dist/cjs/src/utils/match-glob.cjs +19 -9
- package/dist/cjs/src/utils/match-glob.cjs.map +2 -2
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/src/utils/flag-parser.mjs +9 -1
- package/dist/mjs/src/utils/flag-parser.mjs.map +3 -3
- package/package.json +1 -1
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -107,4 +117,4 @@ var tail = async (ctx) => {
|
|
|
107
117
|
return 0;
|
|
108
118
|
};
|
|
109
119
|
|
|
110
|
-
//# debugId=
|
|
120
|
+
//# debugId=B6713ACEB46F636364756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\ninterface TailFlags {\n lines: number;\n}\n\nconst spec = {\n name: \"tail\",\n flags: [\n { short: \"n\", long: \"lines\", takesValue: true },\n ] as FlagDefinition[],\n usage: \"tail [-n lines] [file ...]\",\n};\n\nconst defaults: TailFlags = { lines: 10 };\n\nconst handler = (flags: TailFlags, flag: FlagDefinition, value?: string) => {\n if (flag.short === \"n\" && value) {\n flags.lines = parseInt(value, 10);\n }\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nexport const tail: Command = async (ctx) => {\n // Pre-process args to handle legacy -N format (e.g., -5 means -n 5)\n const processedArgs: string[] = [];\n for (const arg of ctx.args) {\n if (arg.startsWith(\"-\") && /^-\\d+$/.test(arg)) {\n processedArgs.push(\"-n\", arg.slice(1));\n } else {\n processedArgs.push(arg);\n }\n }\n\n const result = parser.parse(processedArgs);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const numLines = result.flags.lines;\n const files = result.args;\n\n if (isNaN(numLines) || numLines < 0) {\n await ctx.stderr.writeText(\"tail: invalid number of lines\\n\");\n return 1;\n }\n\n const outputLines = async (content: string) => {\n const lines = content.split(\"\\n\");\n // Remove trailing empty line if present\n if (lines[lines.length - 1] === \"\") {\n lines.pop();\n }\n const toOutput = lines.slice(-numLines);\n for (const line of toOutput) {\n await ctx.stdout.writeText(line + \"\\n\");\n }\n };\n\n if (files.length === 0) {\n // Read from stdin\n const content = await ctx.stdin.text();\n await outputLines(content);\n } else {\n for (let i = 0; i < files.length; i++) {\n const file = files[i]!;\n try {\n if (files.length > 1) {\n if (i > 0) await ctx.stdout.writeText(\"\\n\");\n await ctx.stdout.writeText(`==> ${file} <==\\n`);\n }\n const path = ctx.fs.resolve(ctx.cwd, file);\n const content = (await ctx.fs.readFile(path)).toString();\n await outputLines(content);\n } catch (err) {\n await ctx.stderr.writeText(`tail: ${file}: No such file or directory\\n`);\n return 1;\n }\n }\n }\n\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACsD,IAAtD;AAMA,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,IACL,EAAE,OAAO,KAAK,MAAM,SAAS,YAAY,KAAK;AAAA,EAChD;AAAA,EACA,OAAO;AACT;AAEA,IAAM,WAAsB,EAAE,OAAO,GAAG;AAExC,IAAM,UAAU,CAAC,OAAkB,MAAsB,UAAmB;AAAA,EAC1E,IAAI,KAAK,UAAU,OAAO,OAAO;AAAA,IAC/B,MAAM,QAAQ,SAAS,OAAO,EAAE;AAAA,EAClC;AAAA;AAGF,IAAM,SAAS,oCAAiB,MAAM,UAAU,OAAO;AAEhD,IAAM,O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AAA,UACpB,IAAI,IAAI;AAAA,YAAG,MAAM,IAAI,OAAO,UAAU;AAAA,CAAI;AAAA,UAC1C,MAAM,IAAI,OAAO,UAAU,OAAO;AAAA,CAAY;AAAA,QAChD;AAAA,QACA,MAAM,OAAO,IAAI,GAAG,QAAQ,IAAI,KAAK,IAAI;AAAA,QACzC,MAAM,WAAW,MAAM,IAAI,GAAG,SAAS,IAAI,GAAG,SAAS;AAAA,QACvD,MAAM,YAAY,OAAO;AAAA,QACzB,OAAO,KAAK;AAAA,QACZ,MAAM,IAAI,OAAO,UAAU,SAAS;AAAA,CAAmC;AAAA,QACvE,OAAO;AAAA;AAAA,IAEX;AAAA;AAAA,EAGF,OAAO;AAAA;",
|
|
8
|
+
"debugId": "B6713ACEB46F636364756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -73,4 +83,4 @@ var tee = async (ctx) => {
|
|
|
73
83
|
return 0;
|
|
74
84
|
};
|
|
75
85
|
|
|
76
|
-
//# debugId=
|
|
86
|
+
//# debugId=BBFC2FCECC25DFBE64756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\ninterface TeeFlags {\n append: boolean;\n}\n\nconst spec = {\n name: \"tee\",\n flags: [\n { short: \"a\", long: \"append\" },\n ] as FlagDefinition[],\n usage: \"tee [-a] [file ...]\",\n};\n\nconst defaults: TeeFlags = { append: false };\n\nconst handler = (flags: TeeFlags, flag: FlagDefinition) => {\n if (flag.short === \"a\") flags.append = true;\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nexport const tee: Command = async (ctx) => {\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const files = result.args;\n\n // Read all stdin content\n const content = await ctx.stdin.buffer();\n\n // Write to stdout\n await ctx.stdout.write(new Uint8Array(content));\n\n // Write to each file\n for (const file of files) {\n const path = ctx.fs.resolve(ctx.cwd, file);\n try {\n if (result.flags.append) {\n await ctx.fs.appendFile(path, content);\n } else {\n await ctx.fs.writeFile(path, content);\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`tee: ${file}: ${message}\\n`);\n return 1;\n }\n }\n\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACsD,IAAtD;AAMA,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,IACL,EAAE,OAAO,KAAK,MAAM,SAAS;AAAA,EAC/B;AAAA,EACA,OAAO;AACT;AAEA,IAAM,WAAqB,EAAE,QAAQ,MAAM;AAE3C,IAAM,UAAU,CAAC,OAAiB,SAAyB;AAAA,EACzD,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,SAAS;AAAA;AAGzC,IAAM,SAAS,oCAAiB,MAAM,UAAU,OAAO;AAEhD,IAAM,MAAe,OAAO,QAAQ;AAAA,EACzC,MAAM,SAAS,OAAO,MAAM,IAAI,IAAI;AAAA,EAEpC,IAAI,OAAO,OAAO;AAAA,IAChB,MAAM,OAAO,WAAW,OAAO,OAAO,IAAI,MAAM;AAAA,IAChD,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,QAAQ,OAAO;AAAA,EAGrB,MAAM,UAAU,MAAM,IAAI,MAAM,OAAO;AAAA,EAGvC,MAAM,IAAI,OAAO,MAAM,IAAI,WAAW,OAAO,CAAC;AAAA,EAG9C,WAAW,QAAQ,OAAO;AAAA,IACxB,MAAM,OAAO,IAAI,GAAG,QAAQ,IAAI,KAAK,IAAI;AAAA,IACzC,IAAI;AAAA,MACF,IAAI,OAAO,MAAM,QAAQ;AAAA,QACvB,MAAM,IAAI,GAAG,WAAW,MAAM,OAAO;AAAA,MACvC,EAAO;AAAA,QACL,MAAM,IAAI,GAAG,UAAU,MAAM,OAAO;AAAA;AAAA,MAEtC,OAAO,KAAK;AAAA,MACZ,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,MAC/D,MAAM,IAAI,OAAO,UAAU,QAAQ,SAAS;AAAA,CAAW;AAAA,MACvD,OAAO;AAAA;AAAA,EAEX;AAAA,EAEA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "BBFC2FCECC25DFBE64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -145,4 +155,4 @@ var test = async (ctx) => {
|
|
|
145
155
|
};
|
|
146
156
|
var bracket = test;
|
|
147
157
|
|
|
148
|
-
//# debugId=
|
|
158
|
+
//# debugId=4EA539996973755A64756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\n\nexport const test: Command = async (ctx) => {\n const args = [...ctx.args];\n\n // Handle [ ... ] syntax - remove trailing ]\n if (args[args.length - 1] === \"]\") {\n args.pop();\n }\n\n if (args.length === 0) {\n return 1; // Empty test is false\n }\n\n // Single argument: true if non-empty string\n if (args.length === 1) {\n return args[0]!.length > 0 ? 0 : 1;\n }\n\n // Two arguments: unary operators\n if (args.length === 2) {\n const [op, operand] = args;\n\n switch (op) {\n case \"-n\": // Non-zero length\n return operand!.length > 0 ? 0 : 1;\n case \"-z\": // Zero length\n return operand!.length === 0 ? 0 : 1;\n case \"-f\": // Is regular file\n try {\n const path = ctx.fs.resolve(ctx.cwd, operand!);\n const stat = await ctx.fs.stat(path);\n return stat.isFile() ? 0 : 1;\n } catch {\n return 1;\n }\n case \"-d\": // Is directory\n try {\n const path = ctx.fs.resolve(ctx.cwd, operand!);\n const stat = await ctx.fs.stat(path);\n return stat.isDirectory() ? 0 : 1;\n } catch {\n return 1;\n }\n case \"-e\": // Exists\n try {\n const path = ctx.fs.resolve(ctx.cwd, operand!);\n return (await ctx.fs.exists(path)) ? 0 : 1;\n } catch {\n return 1;\n }\n case \"-s\": // Has size > 0\n try {\n const path = ctx.fs.resolve(ctx.cwd, operand!);\n const stat = await ctx.fs.stat(path);\n return stat.size > 0 ? 0 : 1;\n } catch {\n return 1;\n }\n case \"-r\": // Readable (always true in virtual fs)\n case \"-w\": // Writable (always true in virtual fs)\n case \"-x\": // Executable (always true in virtual fs)\n try {\n const path = ctx.fs.resolve(ctx.cwd, operand!);\n return (await ctx.fs.exists(path)) ? 0 : 1;\n } catch {\n return 1;\n }\n case \"!\": // Negation\n return operand!.length > 0 ? 1 : 0;\n default:\n await ctx.stderr.writeText(`test: unknown operator: ${op}\\n`);\n return 2;\n }\n }\n\n // Three arguments: binary operators\n if (args.length === 3) {\n const [left, op, right] = args;\n\n // Handle negation with two-arg expression\n if (left === \"!\") {\n const innerResult = await test({\n ...ctx,\n args: [op!, right!],\n });\n return innerResult === 0 ? 1 : 0;\n }\n\n switch (op) {\n case \"=\":\n case \"==\":\n return left === right ? 0 : 1;\n case \"!=\":\n return left !== right ? 0 : 1;\n case \"-eq\":\n return parseInt(left!, 10) === parseInt(right!, 10) ? 0 : 1;\n case \"-ne\":\n return parseInt(left!, 10) !== parseInt(right!, 10) ? 0 : 1;\n case \"-lt\":\n return parseInt(left!, 10) < parseInt(right!, 10) ? 0 : 1;\n case \"-le\":\n return parseInt(left!, 10) <= parseInt(right!, 10) ? 0 : 1;\n case \"-gt\":\n return parseInt(left!, 10) > parseInt(right!, 10) ? 0 : 1;\n case \"-ge\":\n return parseInt(left!, 10) >= parseInt(right!, 10) ? 0 : 1;\n default:\n await ctx.stderr.writeText(`test: unknown operator: ${op}\\n`);\n return 2;\n }\n }\n\n // Four arguments: handle negation with three-arg expression\n if (args.length === 4 && args[0] === \"!\") {\n const innerResult = await test({\n ...ctx,\n args: args.slice(1),\n });\n return innerResult === 0 ? 1 : 0;\n }\n\n await ctx.stderr.writeText(\"test: too many arguments\\n\");\n return 2;\n};\n\n// Alias for [ command\nexport const bracket: Command = test;\n"
|
|
6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,OAAO,SAAS,MAAO,EAAE,IAAI,SAAS,OAAQ,EAAE,IAAI,IAAI;AAAA,WACrD;AAAA,QACH,OAAO,SAAS,MAAO,EAAE,KAAK,SAAS,OAAQ,EAAE,IAAI,IAAI;AAAA,WACtD;AAAA,QACH,OAAO,SAAS,MAAO,EAAE,IAAI,SAAS,OAAQ,EAAE,IAAI,IAAI;AAAA,WACrD;AAAA,QACH,OAAO,SAAS,MAAO,EAAE,KAAK,SAAS,OAAQ,EAAE,IAAI,IAAI;AAAA;AAAA,QAEzD,MAAM,IAAI,OAAO,UAAU,2BAA2B;AAAA,CAAM;AAAA,QAC5D,OAAO;AAAA;AAAA,EAEb;AAAA,EAGA,IAAI,KAAK,WAAW,KAAK,KAAK,OAAO,KAAK;AAAA,IACxC,MAAM,cAAc,MAAM,KAAK;AAAA,SAC1B;AAAA,MACH,MAAM,KAAK,MAAM,CAAC;AAAA,IACpB,CAAC;AAAA,IACD,OAAO,gBAAgB,IAAI,IAAI;AAAA,EACjC;AAAA,EAEA,MAAM,IAAI,OAAO,UAAU;AAAA,CAA4B;AAAA,EACvD,OAAO;AAAA;AAIF,IAAM,UAAmB;",
|
|
8
|
+
"debugId": "4EA539996973755A64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -78,4 +88,4 @@ var touch = async (ctx) => {
|
|
|
78
88
|
return 0;
|
|
79
89
|
};
|
|
80
90
|
|
|
81
|
-
//# debugId=
|
|
91
|
+
//# debugId=C657F1B4D793856F64756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\ninterface TouchFlags {\n noCreate: boolean;\n}\n\nconst spec = {\n name: \"touch\",\n flags: [\n { short: \"c\", long: \"no-create\" },\n ] as FlagDefinition[],\n usage: \"touch [-c] file ...\",\n};\n\nconst defaults: TouchFlags = { noCreate: false };\n\nconst handler = (flags: TouchFlags, flag: FlagDefinition) => {\n if (flag.short === \"c\") flags.noCreate = true;\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nexport const touch: Command = async (ctx) => {\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const files = result.args;\n\n if (files.length === 0) {\n await ctx.stderr.writeText(\"touch: missing file operand\\n\");\n return 1;\n }\n\n for (const file of files) {\n const path = ctx.fs.resolve(ctx.cwd, file);\n try {\n const exists = await ctx.fs.exists(path);\n if (exists) {\n // Update mtime by reading and writing back\n const content = await ctx.fs.readFile(path);\n await ctx.fs.writeFile(path, content);\n } else if (!result.flags.noCreate) {\n // Create empty file\n await ctx.fs.writeFile(path, \"\");\n }\n // If noCreate and doesn't exist, skip silently\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`touch: cannot touch '${file}': ${message}\\n`);\n return 1;\n }\n }\n\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACsD,IAAtD;AAMA,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,IACL,EAAE,OAAO,KAAK,MAAM,YAAY;AAAA,EAClC;AAAA,EACA,OAAO;AACT;AAEA,IAAM,WAAuB,EAAE,UAAU,MAAM;AAE/C,IAAM,UAAU,CAAC,OAAmB,SAAyB;AAAA,EAC3D,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,WAAW;AAAA;AAG3C,IAAM,SAAS,oCAAiB,MAAM,UAAU,OAAO;AAEhD,IAAM,QAAiB,OAAO,QAAQ;AAAA,EAC3C,MAAM,SAAS,OAAO,MAAM,IAAI,IAAI;AAAA,EAEpC,IAAI,OAAO,OAAO;AAAA,IAChB,MAAM,OAAO,WAAW,OAAO,OAAO,IAAI,MAAM;AAAA,IAChD,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,QAAQ,OAAO;AAAA,EAErB,IAAI,MAAM,WAAW,GAAG;AAAA,IACtB,MAAM,IAAI,OAAO,UAAU;AAAA,CAA+B;AAAA,IAC1D,OAAO;AAAA,EACT;AAAA,EAEA,WAAW,QAAQ,OAAO;AAAA,IACxB,MAAM,OAAO,IAAI,GAAG,QAAQ,IAAI,KAAK,IAAI;AAAA,IACzC,IAAI;AAAA,MACF,MAAM,SAAS,MAAM,IAAI,GAAG,OAAO,IAAI;AAAA,MACvC,IAAI,QAAQ;AAAA,QAEV,MAAM,UAAU,MAAM,IAAI,GAAG,SAAS,IAAI;AAAA,QAC1C,MAAM,IAAI,GAAG,UAAU,MAAM,OAAO;AAAA,MACtC,EAAO,SAAI,CAAC,OAAO,MAAM,UAAU;AAAA,QAEjC,MAAM,IAAI,GAAG,UAAU,MAAM,EAAE;AAAA,MACjC;AAAA,MAEA,OAAO,KAAK;AAAA,MACZ,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,MAC/D,MAAM,IAAI,OAAO,UAAU,wBAAwB,UAAU;AAAA,CAAW;AAAA,MACxE,OAAO;AAAA;AAAA,EAEX;AAAA,EAEA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "C657F1B4D793856F64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -180,4 +190,4 @@ var tr = async (ctx) => {
|
|
|
180
190
|
return 0;
|
|
181
191
|
};
|
|
182
192
|
|
|
183
|
-
//# debugId=
|
|
193
|
+
//# debugId=26BBC8DC239649FA64756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\nimport { expandEscapes } from \"../../utils/expand-escapes.cjs\";\n\ninterface TrFlags {\n delete: boolean;\n squeeze: boolean;\n complement: boolean;\n}\n\nconst spec = {\n name: \"tr\",\n flags: [\n { short: \"d\", long: \"delete\" },\n { short: \"s\", long: \"squeeze-repeats\" },\n { short: \"c\", long: \"complement\" },\n { short: \"C\", long: \"complement-values\" },\n ] as FlagDefinition[],\n usage: \"tr [-cCds] SET1 [SET2]\",\n};\n\nconst defaults: TrFlags = { delete: false, squeeze: false, complement: false };\n\nconst handler = (flags: TrFlags, flag: FlagDefinition) => {\n if (flag.short === \"d\") flags.delete = true;\n if (flag.short === \"s\") flags.squeeze = true;\n if (flag.short === \"c\" || flag.short === \"C\") flags.complement = true;\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\n\nfunction expandCharClass(name: string): string {\n switch (name) {\n case \"alpha\": return expandRange(\"a-zA-Z\");\n case \"digit\": return \"0123456789\";\n case \"alnum\": return expandRange(\"a-zA-Z\") + \"0123456789\";\n case \"lower\": return expandRange(\"a-z\");\n case \"upper\": return expandRange(\"A-Z\");\n case \"space\": return \" \\t\\n\\r\\f\\v\";\n case \"blank\": return \" \\t\";\n case \"print\": return expandRange(\" -~\");\n case \"graph\": return expandRange(\"!-~\");\n case \"punct\": return \"!\\\"#$%&'()*+,-./:;<=>?@[\\\\]^_`{|}~\";\n case \"cntrl\": return Array.from({ length: 32 }, (_, i) => String.fromCharCode(i)).join(\"\") + String.fromCharCode(127);\n case \"xdigit\": return \"0123456789abcdefABCDEF\";\n default: return \"\";\n }\n}\n\nfunction expandRange(s: string): string {\n let result = \"\";\n for (let i = 0; i < s.length; i++) {\n if (i + 2 < s.length && s[i + 1] === \"-\") {\n const start = s.charCodeAt(i);\n const end = s.charCodeAt(i + 2);\n for (let c = start; c <= end; c++) {\n result += String.fromCharCode(c);\n }\n i += 2;\n } else {\n result += s[i];\n }\n }\n return result;\n}\n\nfunction expandSet(s: string): string {\n // First expand escape sequences\n s = expandEscapes(s);\n // Expand character classes [:name:]\n s = s.replace(/\\[:(\\w+):\\]/g, (_, name) => expandCharClass(name));\n // Expand ranges\n return expandRange(s);\n}\n\nexport const tr: Command = async (ctx) => {\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const { delete: deleteMode, squeeze, complement } = result.flags;\n const args = result.args;\n\n if (args.length < 1) {\n await ctx.stderr.writeText(\"tr: missing operand\\n\");\n return 1;\n }\n\n let set1 = expandSet(args[0]!);\n const set2 = args.length > 1 ? expandSet(args[1]!) : \"\";\n\n if (complement) {\n // Build complement: all chars 0-127 not in set1\n const set1Chars = new Set(set1);\n let comp = \"\";\n for (let i = 0; i < 128; i++) {\n const ch = String.fromCharCode(i);\n if (!set1Chars.has(ch)) comp += ch;\n }\n set1 = comp;\n }\n\n const input = await ctx.stdin.text();\n let output = \"\";\n\n if (deleteMode && squeeze) {\n // -ds: delete chars in SET1, then squeeze chars in SET2\n const deleteSet = new Set(set1);\n const squeezeSet = new Set(set2);\n let lastChar = \"\";\n for (const ch of input) {\n if (deleteSet.has(ch)) continue;\n if (squeezeSet.has(ch) && ch === lastChar) continue;\n output += ch;\n lastChar = ch;\n }\n } else if (deleteMode) {\n const deleteSet = new Set(set1);\n for (const ch of input) {\n if (!deleteSet.has(ch)) output += ch;\n }\n } else if (squeeze && set2 === \"\") {\n // -s with only SET1: squeeze chars in SET1\n const squeezeSet = new Set(set1);\n let lastChar = \"\";\n for (const ch of input) {\n if (squeezeSet.has(ch) && ch === lastChar) continue;\n output += ch;\n lastChar = ch;\n }\n } else {\n // Translation mode (possibly with -s)\n const map = new Map<string, string>();\n for (let i = 0; i < set1.length; i++) {\n const replacement = i < set2.length ? set2[i]! : set2[set2.length - 1] ?? \"\";\n map.set(set1[i]!, replacement);\n }\n\n const squeezeSet = squeeze ? new Set(set2) : null;\n let lastChar = \"\";\n\n for (const ch of input) {\n const mapped = map.has(ch) ? map.get(ch)! : ch;\n if (squeezeSet && squeezeSet.has(mapped) && mapped === lastChar) continue;\n output += mapped;\n lastChar = mapped;\n }\n }\n\n await ctx.stdout.writeText(output);\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mapp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EAAG,IAAI,KAAK,QAAQ,KAAK;AAAA,MACpC,MAAM,cAAc,IAAI,KAAK,SAAS,KAAK,KAAM,KAAK,KAAK,SAAS,MAAM;AAAA,MAC1E,IAAI,IAAI,KAAK,IAAK,WAAW;AAAA,IAC/B;AAAA,IAEA,MAAM,aAAa,UAAU,IAAI,IAAI,IAAI,IAAI;AAAA,IAC7C,IAAI,WAAW;AAAA,IAEf,WAAW,MAAM,OAAO;AAAA,MACtB,MAAM,SAAS,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,IAAK;AAAA,MAC5C,IAAI,cAAc,WAAW,IAAI,MAAM,KAAK,WAAW;AAAA,QAAU;AAAA,MACjE,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA;AAAA,EAGF,MAAM,IAAI,OAAO,UAAU,MAAM;AAAA,EACjC,OAAO;AAAA;",
|
|
8
|
+
"debugId": "26BBC8DC239649FA64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -169,4 +179,4 @@ ${dirCount} ${dirWord}, ${fileCount} ${fileWord}
|
|
|
169
179
|
return 0;
|
|
170
180
|
};
|
|
171
181
|
|
|
172
|
-
//# debugId=
|
|
182
|
+
//# debugId=84C05E2FE694C09E64756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\nimport { matchGlob } from \"../../utils/match-glob.cjs\";\n\ninterface TreeFlags {\n all: boolean;\n directoriesOnly: boolean;\n maxDepth: number;\n dirsfirst: boolean;\n ignorePatterns: string[];\n}\n\nconst spec = {\n name: \"tree\",\n flags: [\n { short: \"a\", long: \"all\" },\n { short: \"d\" },\n { short: \"L\", takesValue: true },\n { short: \"I\", takesValue: true },\n { long: \"dirsfirst\" },\n ] as FlagDefinition[],\n usage: \"tree [-adI] [-L level] [-I pattern] [--dirsfirst] [directory ...]\",\n};\n\nconst defaults: TreeFlags = { all: false, directoriesOnly: false, maxDepth: Infinity, dirsfirst: true, ignorePatterns: [] };\n\ninterface HandlerResult {\n error?: string;\n}\n\nlet handlerResult: HandlerResult = {};\n\nconst handler = (flags: TreeFlags, flag: FlagDefinition, value?: string) => {\n if (flag.short === \"a\") flags.all = true;\n if (flag.short === \"d\") flags.directoriesOnly = true;\n if (flag.long === \"dirsfirst\") flags.dirsfirst = true;\n if (flag.short === \"I\" && value) {\n if (flags.ignorePatterns === defaults.ignorePatterns) {\n flags.ignorePatterns = [];\n }\n flags.ignorePatterns.push(...value.split(\"|\"));\n }\n if (flag.short === \"L\" && value) {\n const depth = parseInt(value, 10);\n if (isNaN(depth) || !/^\\d+$/.test(value)) {\n handlerResult.error = `tree: -L option requires a numeric argument\\nusage: ${spec.usage}\\n`;\n } else {\n flags.maxDepth = depth;\n }\n }\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nexport const tree: Command = async (ctx) => {\n // Reset handler result for each invocation\n handlerResult = {};\n\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n if (handlerResult.error) {\n await ctx.stderr.writeText(handlerResult.error);\n return 1;\n }\n\n const { all: showAll, directoriesOnly, maxDepth, ignorePatterns } = result.flags;\n const targetPath = result.args[0] ?? \".\";\n\n // Validate maxDepth\n if (maxDepth < 1) {\n await ctx.stderr.writeText(\"tree: Invalid level, must be greater than 0\\n\");\n return 1;\n }\n\n const resolvedPath = ctx.fs.resolve(ctx.cwd, targetPath);\n\n // Check if path exists\n let stat;\n try {\n stat = await ctx.fs.stat(resolvedPath);\n } catch {\n await ctx.stderr.writeText(`tree: ${targetPath}: No such file or directory\\n`);\n return 1;\n }\n\n // If it's a file, just print the filename\n if (stat.isFile()) {\n await ctx.stdout.writeText(targetPath + \"\\n\\n0 directories, 1 file\\n\");\n return 0;\n }\n\n let dirCount = 0;\n let fileCount = 0;\n\n // Print root\n await ctx.stdout.writeText(targetPath + \"\\n\");\n\n // Recursive function to build tree\n async function printTree(path: string, prefix: string, depth: number): Promise<void> {\n if (depth > maxDepth) return;\n\n let entries = await ctx.fs.readdir(path);\n\n // Filter hidden files unless -a\n if (!showAll) {\n entries = entries.filter((e) => !e.startsWith(\".\"));\n }\n\n // Filter by -I ignore patterns\n if (ignorePatterns.length > 0) {\n entries = entries.filter((e) => !ignorePatterns.some((p) => matchGlob(p, e)));\n }\n\n // Sort entries\n entries.sort();\n\n // Separate dirs and files, dirs first\n const dirEntries: string[] = [];\n const fileEntries: string[] = [];\n\n for (const entry of entries) {\n const entryPath = ctx.fs.resolve(path, entry);\n try {\n const entryStat = await ctx.fs.stat(entryPath);\n if (entryStat.isDirectory()) {\n dirEntries.push(entry);\n } else {\n fileEntries.push(entry);\n }\n } catch {\n // Skip entries we can't stat\n }\n }\n\n // Combine: directories first, then files (unless directoriesOnly)\n const sortedEntries = directoriesOnly\n ? dirEntries\n : [...dirEntries, ...fileEntries];\n\n for (let i = 0; i < sortedEntries.length; i++) {\n const entry = sortedEntries[i]!;\n const isLast = i === sortedEntries.length - 1;\n const connector = isLast ? \"└── \" : \"├── \";\n const entryPath = ctx.fs.resolve(path, entry);\n\n let isDir = false;\n try {\n const entryStat = await ctx.fs.stat(entryPath);\n isDir = entryStat.isDirectory();\n } catch {\n continue;\n }\n\n await ctx.stdout.writeText(prefix + connector + entry + \"\\n\");\n\n if (isDir) {\n dirCount++;\n if (depth < maxDepth) {\n const newPrefix = prefix + (isLast ? \" \" : \"│ \");\n await printTree(entryPath, newPrefix, depth + 1);\n }\n } else {\n fileCount++;\n }\n }\n }\n\n await printTree(resolvedPath, \"\", 1);\n\n // Print summary\n const dirWord = dirCount === 1 ? \"directory\" : \"directories\";\n const fileWord = fileCount === 1 ? \"file\" : \"files\";\n await ctx.stdout.writeText(`\\n${dirCount} ${dirWord}, ${fileCount} ${fileWord}\\n`);\n\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|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SAAS,SAAS;AAAA,UAC9C,MAAM,UAAU,WAAW,WAAW,QAAQ,CAAC;AAAA,QACjD;AAAA,MACF,EAAO;AAAA,QACL;AAAA;AAAA,IAEJ;AAAA;AAAA,EAGF,MAAM,UAAU,cAAc,IAAI,CAAC;AAAA,EAGnC,MAAM,UAAU,aAAa,IAAI,cAAc;AAAA,EAC/C,MAAM,WAAW,cAAc,IAAI,SAAS;AAAA,EAC5C,MAAM,IAAI,OAAO,UAAU;AAAA,EAAK,YAAY,YAAY,aAAa;AAAA,CAAY;AAAA,EAEjF,OAAO;AAAA;",
|
|
8
|
+
"debugId": "84C05E2FE694C09E64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -40,4 +50,4 @@ var falseCmd = async () => {
|
|
|
40
50
|
return 1;
|
|
41
51
|
};
|
|
42
52
|
|
|
43
|
-
//# debugId=
|
|
53
|
+
//# debugId=C43BABF18303D70564756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\n\nexport const trueCmd: Command = async () => {\n return 0;\n};\n\nexport const falseCmd: Command = async () => {\n return 1;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,UAAmB,YAAY;AAAA,EAC1C,OAAO;AAAA;AAGF,IAAM,WAAoB,YAAY;AAAA,EAC3C,OAAO;AAAA;",
|
|
8
|
+
"debugId": "C43BABF18303D70564756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -116,4 +126,4 @@ var uniq = async (ctx) => {
|
|
|
116
126
|
return 0;
|
|
117
127
|
};
|
|
118
128
|
|
|
119
|
-
//# debugId=
|
|
129
|
+
//# debugId=AF2908712020482464756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\ninterface UniqFlags {\n count: boolean;\n duplicates: boolean;\n unique: boolean;\n}\n\nconst spec = {\n name: \"uniq\",\n flags: [\n { short: \"c\", long: \"count\" },\n { short: \"d\", long: \"repeated\" },\n { short: \"u\", long: \"unique\" },\n ] as FlagDefinition[],\n usage: \"uniq [-cdu] [input [output]]\",\n};\n\nconst defaults: UniqFlags = { count: false, duplicates: false, unique: false };\n\nconst handler = (flags: UniqFlags, flag: FlagDefinition) => {\n if (flag.short === \"c\") flags.count = true;\n if (flag.short === \"d\") flags.duplicates = true;\n if (flag.short === \"u\") flags.unique = true;\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nexport const uniq: Command = async (ctx) => {\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const { count: countMode, duplicates: duplicatesOnly, unique: uniqueOnly } = result.flags;\n const files = result.args;\n\n let lines: string[] = [];\n\n if (files.length === 0) {\n for await (const line of ctx.stdin.lines()) {\n lines.push(line);\n }\n } else {\n const file = files[0]!;\n try {\n const path = ctx.fs.resolve(ctx.cwd, file);\n const content = (await ctx.fs.readFile(path)).toString();\n lines = content.split(\"\\n\");\n if (lines[lines.length - 1] === \"\") {\n lines.pop();\n }\n } catch (err) {\n await ctx.stderr.writeText(`uniq: ${file}: No such file or directory\\n`);\n return 1;\n }\n }\n\n // Process lines\n const results: Array<{ line: string; count: number }> = [];\n let currentLine: string | null = null;\n let currentCount = 0;\n\n for (const line of lines) {\n if (line === currentLine) {\n currentCount++;\n } else {\n if (currentLine !== null) {\n results.push({ line: currentLine, count: currentCount });\n }\n currentLine = line;\n currentCount = 1;\n }\n }\n if (currentLine !== null) {\n results.push({ line: currentLine, count: currentCount });\n }\n\n // Output\n for (const { line, count } of results) {\n const isDuplicate = count > 1;\n const isUnique = count === 1;\n\n if (duplicatesOnly && !isDuplicate) continue;\n if (uniqueOnly && !isUnique) continue;\n\n if (countMode) {\n await ctx.stdout.writeText(`${String(count).padStart(7)} ${line}\\n`);\n } else {\n await ctx.stdout.writeText(line + \"\\n\");\n }\n }\n\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACsD,IAAtD;AAQA,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,IACL,EAAE,OAAO,KAAK,MAAM,QAAQ;AAAA,IAC5B,EAAE,OAAO,KAAK,MAAM,WAAW;AAAA,IAC/B,EAAE,OAAO,KAAK,MAAM,SAAS;AAAA,EAC/B;AAAA,EACA,OAAO;AACT;AAEA,IAAM,WAAsB,EAAE,OAAO,OAAO,YAAY,OAAO,QAAQ,MAAM;AAE7E,IAAM,UAAU,CAAC,OAAkB,SAAyB;AAAA,EAC1D,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,QAAQ;AAAA,EACtC,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,aAAa;AAAA,EAC3C,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,SAAS;AAAA;AAGzC,IAAM,SAAS,oCAAiB,MAAM,UAAU,OAAO;AAEhD,IAAM,OAAgB,OAAO,QAAQ;AAAA,EAC1C,MAAM,SAAS,OAAO,MAAM,IAAI,IAAI;AAAA,EAEpC,IAAI,OAAO,OAAO;AAAA,IAChB,MAAM,OAAO,WAAW,OAAO,OAAO,IAAI,MAAM;AAAA,IAChD,OAAO;AAAA,EACT;AAAA,EAEA,QAAQ,OAAO,WAAW,YAAY,gBAAgB,QAAQ,eAAe,OAAO;AAAA,EACpF,MAAM,QAAQ,OAAO;AAAA,EAErB,IAAI,QAAkB,CAAC;AAAA,EAEvB,IAAI,MAAM,WAAW,GAAG;AAAA,IACtB,iBAAiB,QAAQ,IAAI,MAAM,MAAM,GAAG;AAAA,MAC1C,MAAM,KAAK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