typescript-virtual-container 1.2.9 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +0 -1
- package/README.md +141 -50
- package/biome.json +7 -0
- package/dist/SSHMimic/exec.d.ts.map +1 -1
- package/dist/SSHMimic/executor.d.ts.map +1 -1
- package/dist/SSHMimic/executor.js +32 -16
- package/dist/SSHMimic/index.d.ts.map +1 -1
- package/dist/SSHMimic/index.js +20 -6
- package/dist/VirtualFileSystem/binaryPack.d.ts.map +1 -1
- package/dist/VirtualFileSystem/binaryPack.js +29 -6
- package/dist/VirtualFileSystem/index.d.ts.map +1 -1
- package/dist/VirtualFileSystem/index.js +36 -13
- package/dist/VirtualPackageManager/index.d.ts.map +1 -1
- package/dist/VirtualPackageManager/index.js +192 -43
- package/dist/VirtualShell/index.d.ts +10 -4
- package/dist/VirtualShell/index.d.ts.map +1 -1
- package/dist/VirtualShell/index.js +18 -7
- package/dist/VirtualShell/shell.d.ts.map +1 -1
- package/dist/VirtualShell/shell.js +3 -1
- package/dist/VirtualShell/shellParser.d.ts.map +1 -1
- package/dist/VirtualUserManager/index.d.ts.map +1 -1
- package/dist/commands/adduser.d.ts +6 -0
- package/dist/commands/adduser.d.ts.map +1 -1
- package/dist/commands/adduser.js +6 -0
- package/dist/commands/alias.d.ts +5 -0
- package/dist/commands/alias.d.ts.map +1 -1
- package/dist/commands/alias.js +5 -0
- package/dist/commands/apt.d.ts +5 -0
- package/dist/commands/apt.d.ts.map +1 -1
- package/dist/commands/apt.js +32 -9
- package/dist/commands/awk.d.ts +11 -0
- package/dist/commands/awk.d.ts.map +1 -1
- package/dist/commands/awk.js +15 -2
- package/dist/commands/base64.d.ts +5 -0
- package/dist/commands/base64.d.ts.map +1 -1
- package/dist/commands/base64.js +9 -1
- package/dist/commands/cat.d.ts +5 -0
- package/dist/commands/cat.d.ts.map +1 -1
- package/dist/commands/cat.js +10 -2
- package/dist/commands/cd.d.ts +5 -0
- package/dist/commands/cd.d.ts.map +1 -1
- package/dist/commands/cd.js +5 -0
- package/dist/commands/chmod.d.ts +5 -0
- package/dist/commands/chmod.d.ts.map +1 -1
- package/dist/commands/chmod.js +5 -0
- package/dist/commands/cp.d.ts +5 -0
- package/dist/commands/cp.d.ts.map +1 -1
- package/dist/commands/cp.js +5 -0
- package/dist/commands/curl.d.ts +5 -0
- package/dist/commands/curl.d.ts.map +1 -1
- package/dist/commands/curl.js +34 -6
- package/dist/commands/cut.d.ts +5 -0
- package/dist/commands/cut.d.ts.map +1 -1
- package/dist/commands/cut.js +8 -1
- package/dist/commands/date.d.ts +5 -0
- package/dist/commands/date.d.ts.map +1 -1
- package/dist/commands/date.js +7 -1
- package/dist/commands/declare.d.ts +3 -0
- package/dist/commands/declare.d.ts.map +1 -0
- package/dist/commands/declare.js +39 -0
- package/dist/commands/diff.d.ts +5 -0
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +5 -0
- package/dist/commands/dpkg.d.ts +5 -0
- package/dist/commands/dpkg.d.ts.map +1 -1
- package/dist/commands/dpkg.js +24 -7
- package/dist/commands/du.d.ts.map +1 -1
- package/dist/commands/du.js +8 -2
- package/dist/commands/echo.d.ts +5 -0
- package/dist/commands/echo.d.ts.map +1 -1
- package/dist/commands/echo.js +13 -4
- package/dist/commands/env.d.ts +5 -0
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +11 -1
- package/dist/commands/exit.d.ts +5 -0
- package/dist/commands/exit.d.ts.map +1 -1
- package/dist/commands/exit.js +12 -2
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +3 -1
- package/dist/commands/find.d.ts +5 -0
- package/dist/commands/find.d.ts.map +1 -1
- package/dist/commands/find.js +5 -0
- package/dist/commands/free.d.ts +5 -0
- package/dist/commands/free.d.ts.map +1 -1
- package/dist/commands/free.js +5 -0
- package/dist/commands/grep.d.ts +5 -0
- package/dist/commands/grep.d.ts.map +1 -1
- package/dist/commands/grep.js +12 -2
- package/dist/commands/gzip.d.ts +5 -0
- package/dist/commands/gzip.d.ts.map +1 -1
- package/dist/commands/gzip.js +18 -2
- package/dist/commands/head.d.ts +5 -0
- package/dist/commands/head.d.ts.map +1 -1
- package/dist/commands/head.js +5 -0
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +98 -45
- package/dist/commands/history.d.ts +5 -0
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +5 -0
- package/dist/commands/hostname.d.ts +5 -0
- package/dist/commands/hostname.d.ts.map +1 -1
- package/dist/commands/hostname.js +5 -0
- package/dist/commands/id.d.ts.map +1 -1
- package/dist/commands/id.js +4 -1
- package/dist/commands/index.d.ts +2 -17
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -340
- package/dist/commands/ls.d.ts.map +1 -1
- package/dist/commands/ls.js +3 -1
- package/dist/commands/lsb-release.d.ts.map +1 -1
- package/dist/commands/lsb-release.js +8 -2
- package/dist/commands/nano.js +1 -1
- package/dist/commands/neofetch.js +1 -1
- package/dist/commands/node.d.ts +9 -0
- package/dist/commands/node.d.ts.map +1 -0
- package/dist/commands/node.js +316 -0
- package/dist/commands/npm.d.ts +19 -0
- package/dist/commands/npm.d.ts.map +1 -0
- package/dist/commands/npm.js +109 -0
- package/dist/commands/ping.d.ts.map +1 -1
- package/dist/commands/ping.js +3 -1
- package/dist/commands/printf.d.ts +3 -0
- package/dist/commands/printf.d.ts.map +1 -0
- package/dist/commands/printf.js +113 -0
- package/dist/commands/ps.d.ts.map +1 -1
- package/dist/commands/ps.js +4 -1
- package/dist/commands/python.d.ts +30 -0
- package/dist/commands/python.d.ts.map +1 -0
- package/dist/commands/python.js +2058 -0
- package/dist/commands/read.d.ts +3 -0
- package/dist/commands/read.d.ts.map +1 -0
- package/dist/commands/read.js +34 -0
- package/dist/commands/registry.d.ts +8 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +229 -0
- package/dist/commands/runtime.d.ts +6 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +280 -0
- package/dist/commands/sed.d.ts.map +1 -1
- package/dist/commands/sed.js +11 -3
- package/dist/commands/set.d.ts.map +1 -1
- package/dist/commands/set.js +9 -3
- package/dist/commands/sh.d.ts.map +1 -1
- package/dist/commands/sh.js +57 -36
- package/dist/commands/shift.d.ts +5 -0
- package/dist/commands/shift.d.ts.map +1 -0
- package/dist/commands/shift.js +52 -0
- package/dist/commands/sleep.d.ts.map +1 -1
- package/dist/commands/sort.d.ts.map +1 -1
- package/dist/commands/sort.js +4 -2
- package/dist/commands/source.d.ts.map +1 -1
- package/dist/commands/source.js +5 -2
- package/dist/commands/sudo.js +1 -1
- package/dist/commands/tar.d.ts.map +1 -1
- package/dist/commands/tar.js +11 -3
- package/dist/commands/tee.d.ts.map +1 -1
- package/dist/commands/tee.js +8 -6
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +46 -24
- package/dist/commands/tr.d.ts.map +1 -1
- package/dist/commands/tr.js +3 -1
- package/dist/commands/true.d.ts +4 -0
- package/dist/commands/true.d.ts.map +1 -0
- package/dist/commands/true.js +14 -0
- package/dist/commands/type.d.ts.map +1 -1
- package/dist/commands/type.js +1 -1
- package/dist/commands/uname.d.ts.map +1 -1
- package/dist/commands/uname.js +4 -1
- package/dist/commands/uniq.d.ts.map +1 -1
- package/dist/commands/uptime.d.ts.map +1 -1
- package/dist/commands/uptime.js +4 -1
- package/dist/commands/wget.d.ts.map +1 -1
- package/dist/commands/wget.js +32 -7
- package/dist/commands/which.d.ts.map +1 -1
- package/dist/commands/xargs.d.ts.map +1 -1
- package/dist/commands/xargs.js +1 -1
- package/dist/index.d.ts +15 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/dist/modules/linuxRootfs.d.ts +18 -1
- package/dist/modules/linuxRootfs.d.ts.map +1 -1
- package/dist/modules/linuxRootfs.js +160 -17
- package/dist/standalone-wo-sftp.d.ts +2 -0
- package/dist/standalone-wo-sftp.d.ts.map +1 -0
- package/dist/standalone-wo-sftp.js +30 -0
- package/dist/utils/expand.d.ts +50 -0
- package/dist/utils/expand.d.ts.map +1 -0
- package/dist/utils/expand.js +183 -0
- package/dist/utils/vfsDiff.d.ts +90 -0
- package/dist/utils/vfsDiff.d.ts.map +1 -0
- package/dist/utils/vfsDiff.js +177 -0
- package/package.json +2 -1
- package/src/SSHMimic/exec.ts +10 -1
- package/src/SSHMimic/executor.ts +104 -18
- package/src/SSHMimic/index.ts +49 -15
- package/src/VirtualFileSystem/binaryPack.ts +35 -8
- package/src/VirtualFileSystem/index.ts +78 -28
- package/src/VirtualPackageManager/index.ts +208 -49
- package/src/VirtualShell/index.ts +35 -7
- package/src/VirtualShell/shell.ts +23 -3
- package/src/VirtualShell/shellParser.ts +134 -36
- package/src/VirtualUserManager/index.ts +7 -2
- package/src/commands/adduser.ts +6 -0
- package/src/commands/alias.ts +5 -1
- package/src/commands/apt.ts +47 -17
- package/src/commands/awk.ts +20 -6
- package/src/commands/base64.ts +13 -2
- package/src/commands/cat.ts +13 -5
- package/src/commands/cd.ts +5 -0
- package/src/commands/chmod.ts +5 -0
- package/src/commands/cp.ts +5 -0
- package/src/commands/curl.ts +56 -12
- package/src/commands/cut.ts +8 -1
- package/src/commands/date.ts +7 -1
- package/src/commands/declare.ts +44 -0
- package/src/commands/diff.ts +17 -3
- package/src/commands/dpkg.ts +33 -11
- package/src/commands/du.ts +17 -5
- package/src/commands/echo.ts +22 -9
- package/src/commands/env.ts +11 -1
- package/src/commands/exit.ts +12 -2
- package/src/commands/export.ts +3 -1
- package/src/commands/find.ts +5 -0
- package/src/commands/free.ts +9 -2
- package/src/commands/grep.ts +12 -2
- package/src/commands/gzip.ts +28 -4
- package/src/commands/head.ts +5 -0
- package/src/commands/help.ts +121 -47
- package/src/commands/history.ts +7 -2
- package/src/commands/hostname.ts +5 -0
- package/src/commands/id.ts +4 -1
- package/src/commands/index.ts +9 -360
- package/src/commands/ls.ts +5 -3
- package/src/commands/lsb-release.ts +8 -2
- package/src/commands/nano.ts +1 -1
- package/src/commands/neofetch.ts +1 -1
- package/src/commands/node.ts +341 -0
- package/src/commands/npm.ts +132 -0
- package/src/commands/ping.ts +6 -2
- package/src/commands/printf.ts +112 -0
- package/src/commands/ps.ts +21 -9
- package/src/commands/python.ts +2229 -0
- package/src/commands/read.ts +41 -0
- package/src/commands/registry.ts +244 -0
- package/src/commands/runtime.ts +353 -0
- package/src/commands/sed.ts +27 -9
- package/src/commands/set.ts +9 -3
- package/src/commands/sh.ts +159 -55
- package/src/commands/shift.ts +53 -0
- package/src/commands/sleep.ts +2 -1
- package/src/commands/sort.ts +10 -6
- package/src/commands/source.ts +15 -3
- package/src/commands/sudo.ts +1 -1
- package/src/commands/tar.ts +28 -7
- package/src/commands/tee.ts +7 -1
- package/src/commands/test.ts +61 -26
- package/src/commands/tr.ts +3 -1
- package/src/commands/true.ts +17 -0
- package/src/commands/type.ts +6 -3
- package/src/commands/uname.ts +5 -1
- package/src/commands/uniq.ts +8 -2
- package/src/commands/uptime.ts +4 -1
- package/src/commands/wget.ts +51 -12
- package/src/commands/which.ts +5 -2
- package/src/commands/xargs.ts +11 -2
- package/src/index.ts +23 -24
- package/src/modules/linuxRootfs.ts +233 -30
- package/src/standalone-wo-sftp.ts +38 -0
- package/src/utils/expand.ts +238 -0
- package/src/utils/vfsDiff.ts +275 -0
- package/standalone-wo-sftp.js +507 -0
- package/standalone-wo-sftp.js.map +7 -0
- package/standalone.js +253 -191
- package/standalone.js.map +4 -4
- package/tests/bun-test-shim.ts +9 -1
- package/tests/command-helpers.test.ts +1 -5
- package/tests/new-features.test.ts +415 -5
- package/tests/parser-executor.test.ts +27 -27
- package/tests/sftp.test.ts +122 -42
- package/tests/users.test.ts +23 -5
- package/CHANGELOG.md +0 -150
package/dist/commands/dpkg.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
|
+
/**
|
|
3
|
+
* dpkg compatibility command (query/remove/list) backed by the virtual package manager.
|
|
4
|
+
* @category package
|
|
5
|
+
* @params ["[-l] [-s pkg] [-L pkg] [-i pkg] [--remove pkg]"]
|
|
6
|
+
*/
|
|
2
7
|
export declare const dpkgCommand: ShellModule;
|
|
3
8
|
export declare const dpkgQueryCommand: ShellModule;
|
|
4
9
|
//# sourceMappingURL=dpkg.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dpkg.d.ts","sourceRoot":"","sources":["../../src/commands/dpkg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"dpkg.d.ts","sourceRoot":"","sources":["../../src/commands/dpkg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WA0HzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,WA8C9B,CAAC"}
|
package/dist/commands/dpkg.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { ifFlag, parseArgs } from "./command-helpers";
|
|
2
2
|
import { getPackageManager } from "./helpers";
|
|
3
|
+
/**
|
|
4
|
+
* dpkg compatibility command (query/remove/list) backed by the virtual package manager.
|
|
5
|
+
* @category package
|
|
6
|
+
* @params ["[-l] [-s pkg] [-L pkg] [-i pkg] [--remove pkg]"]
|
|
7
|
+
*/
|
|
3
8
|
export const dpkgCommand = {
|
|
4
9
|
name: "dpkg",
|
|
5
10
|
description: "Debian package manager low-level tool",
|
|
6
|
-
category: "
|
|
11
|
+
category: "package",
|
|
7
12
|
params: ["[-l] [-s pkg] [-L pkg] [-i pkg] [--remove pkg]"],
|
|
8
13
|
run: ({ args, authUser, shell }) => {
|
|
9
14
|
const pm = getPackageManager(shell);
|
|
@@ -15,7 +20,18 @@ export const dpkgCommand = {
|
|
|
15
20
|
const removeFlag = ifFlag(args, ["-r", "--remove"]);
|
|
16
21
|
const purgeFlag = ifFlag(args, ["-P", "--purge"]);
|
|
17
22
|
const { positionals } = parseArgs(args, {
|
|
18
|
-
flags: [
|
|
23
|
+
flags: [
|
|
24
|
+
"-l",
|
|
25
|
+
"--list",
|
|
26
|
+
"-s",
|
|
27
|
+
"--status",
|
|
28
|
+
"-L",
|
|
29
|
+
"--listfiles",
|
|
30
|
+
"-r",
|
|
31
|
+
"--remove",
|
|
32
|
+
"-P",
|
|
33
|
+
"--purge",
|
|
34
|
+
],
|
|
19
35
|
});
|
|
20
36
|
if (listFlag) {
|
|
21
37
|
const pkgList = pm.listInstalled();
|
|
@@ -104,12 +120,15 @@ export const dpkgCommand = {
|
|
|
104
120
|
export const dpkgQueryCommand = {
|
|
105
121
|
name: "dpkg-query",
|
|
106
122
|
description: "Show information about installed packages",
|
|
107
|
-
category: "
|
|
123
|
+
category: "package",
|
|
108
124
|
params: ["-W [pkg] | -l [pattern]"],
|
|
109
125
|
run: ({ args, shell }) => {
|
|
110
126
|
const pm = getPackageManager(shell);
|
|
111
127
|
if (!pm)
|
|
112
|
-
return {
|
|
128
|
+
return {
|
|
129
|
+
stderr: "dpkg-query: package manager not initialised",
|
|
130
|
+
exitCode: 1,
|
|
131
|
+
};
|
|
113
132
|
const listFlag = ifFlag(args, ["-l"]);
|
|
114
133
|
const showFlag = ifFlag(args, ["-W", "--show"]);
|
|
115
134
|
const { positionals } = parseArgs(args, {
|
|
@@ -123,9 +142,7 @@ export const dpkgQueryCommand = {
|
|
|
123
142
|
: pkgList;
|
|
124
143
|
if (showFlag) {
|
|
125
144
|
return {
|
|
126
|
-
stdout: filtered
|
|
127
|
-
.map((p) => `${p.name}\t${p.version}`)
|
|
128
|
-
.join("\n"),
|
|
145
|
+
stdout: filtered.map((p) => `${p.name}\t${p.version}`).join("\n"),
|
|
129
146
|
exitCode: 0,
|
|
130
147
|
};
|
|
131
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"du.d.ts","sourceRoot":"","sources":["../../src/commands/du.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"du.d.ts","sourceRoot":"","sources":["../../src/commands/du.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,eAAO,MAAM,SAAS,EAAE,WA8CvB,CAAC"}
|
package/dist/commands/du.js
CHANGED
|
@@ -12,9 +12,15 @@ export const duCommand = {
|
|
|
12
12
|
const p = resolvePath(cwd, target);
|
|
13
13
|
const fmt = (b) => human ? `${(b / 1024).toFixed(1)}K` : String(Math.ceil(b / 1024));
|
|
14
14
|
if (!shell.vfs.exists(p))
|
|
15
|
-
return {
|
|
15
|
+
return {
|
|
16
|
+
stderr: `du: ${target}: No such file or directory`,
|
|
17
|
+
exitCode: 1,
|
|
18
|
+
};
|
|
16
19
|
if (summary || shell.vfs.stat(p).type === "file") {
|
|
17
|
-
return {
|
|
20
|
+
return {
|
|
21
|
+
stdout: `${fmt(shell.vfs.getUsageBytes(p))}\t${target}`,
|
|
22
|
+
exitCode: 0,
|
|
23
|
+
};
|
|
18
24
|
}
|
|
19
25
|
const lines = [];
|
|
20
26
|
const walk = (dir, rel) => {
|
package/dist/commands/echo.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
|
+
/**
|
|
3
|
+
* Echo text to stdout with shell-style expansion and escape support.
|
|
4
|
+
* @category shell
|
|
5
|
+
* @params ["[-n] [-e] [text...]"]
|
|
6
|
+
*/
|
|
2
7
|
export declare const echoCommand: ShellModule;
|
|
3
8
|
//# sourceMappingURL=echo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"echo.d.ts","sourceRoot":"","sources":["../../src/commands/echo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"echo.d.ts","sourceRoot":"","sources":["../../src/commands/echo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAuBrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WA6BzB,CAAC"}
|
package/dist/commands/echo.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseArgs } from "./command-helpers";
|
|
2
|
+
import { expandSync } from "../utils/expand";
|
|
2
3
|
/**
|
|
3
4
|
* Expand escape sequences for `echo -e`.
|
|
4
5
|
* Handles \n \t \r \\ \a \b \f \v and \0NNN (octal).
|
|
@@ -15,19 +16,27 @@ function expandEscapes(text) {
|
|
|
15
16
|
.replace(/\\v/g, "\x0B")
|
|
16
17
|
.replace(/\\0(\d{1,3})/g, (_, oct) => String.fromCharCode(parseInt(oct, 8)));
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Echo text to stdout with shell-style expansion and escape support.
|
|
21
|
+
* @category shell
|
|
22
|
+
* @params ["[-n] [-e] [text...]"]
|
|
23
|
+
*/
|
|
18
24
|
export const echoCommand = {
|
|
19
25
|
name: "echo",
|
|
20
26
|
description: "Display text",
|
|
21
27
|
category: "shell",
|
|
22
28
|
params: ["[-n] [-e] [text...]"],
|
|
23
29
|
run: ({ args, stdin, env }) => {
|
|
24
|
-
const { flags, positionals } = parseArgs(args, {
|
|
30
|
+
const { flags, positionals } = parseArgs(args, {
|
|
31
|
+
flags: ["-n", "-e", "-E"],
|
|
32
|
+
});
|
|
25
33
|
const noNewline = flags.has("-n");
|
|
26
34
|
const escapes = flags.has("-e");
|
|
27
35
|
const rawText = positionals.length > 0 ? positionals.join(" ") : (stdin ?? "");
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
const
|
|
36
|
+
// Full expansion: $? ${#VAR} $((expr)) ~ ${VAR:-def} $VAR etc.
|
|
37
|
+
// $(cmd) is already resolved upstream by runCommand before echo.run is called.
|
|
38
|
+
const expanded = expandSync(rawText, env?.vars ?? {}, env?.lastExitCode ?? 0);
|
|
39
|
+
const text = escapes ? expandEscapes(expanded) : expanded;
|
|
31
40
|
return {
|
|
32
41
|
stdout: noNewline ? text : `${text}\n`,
|
|
33
42
|
exitCode: 0,
|
package/dist/commands/env.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/** biome-ignore-all lint/style/useNamingConvention: ENV VARS */
|
|
2
2
|
import type { ShellModule } from "../types/commands";
|
|
3
|
+
/**
|
|
4
|
+
* Print environment variables for the current session.
|
|
5
|
+
* @category shell
|
|
6
|
+
* @params []
|
|
7
|
+
*/
|
|
3
8
|
export declare const envCommand: ShellModule;
|
|
4
9
|
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/commands/env.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/commands/env.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,WAcxB,CAAC"}
|
package/dist/commands/env.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Print environment variables for the current session.
|
|
3
|
+
* @category shell
|
|
4
|
+
* @params []
|
|
5
|
+
*/
|
|
1
6
|
export const envCommand = {
|
|
2
7
|
name: "env",
|
|
3
8
|
description: "Print environment variables",
|
|
@@ -5,6 +10,11 @@ export const envCommand = {
|
|
|
5
10
|
params: [],
|
|
6
11
|
run: ({ env, authUser }) => {
|
|
7
12
|
const vars = { ...env.vars, USER: authUser, HOME: `/home/${authUser}` };
|
|
8
|
-
return {
|
|
13
|
+
return {
|
|
14
|
+
stdout: Object.entries(vars)
|
|
15
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
16
|
+
.join("\n"),
|
|
17
|
+
exitCode: 0,
|
|
18
|
+
};
|
|
9
19
|
},
|
|
10
20
|
};
|
package/dist/commands/exit.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../../src/commands/exit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../../src/commands/exit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAUzB,CAAC"}
|
package/dist/commands/exit.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exit the current shell session (closeSession flag).
|
|
3
|
+
* @category shell
|
|
4
|
+
* @params ["[code]"]
|
|
5
|
+
*/
|
|
1
6
|
export const exitCommand = {
|
|
2
7
|
name: "exit",
|
|
3
8
|
aliases: ["bye"],
|
|
4
|
-
|
|
5
|
-
|
|
9
|
+
description: "Exit the shell session",
|
|
10
|
+
category: "shell",
|
|
11
|
+
params: ["[code]"],
|
|
12
|
+
run: ({ args }) => ({
|
|
13
|
+
closeSession: true,
|
|
14
|
+
exitCode: parseInt(args[0] ?? "0", 10) || 0,
|
|
15
|
+
}),
|
|
6
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,aAAa,EAAE,WAwB3B,CAAC"}
|
package/dist/commands/export.js
CHANGED
|
@@ -5,7 +5,9 @@ export const exportCommand = {
|
|
|
5
5
|
params: ["[VAR=value]"],
|
|
6
6
|
run: ({ args, env }) => {
|
|
7
7
|
if (args.length === 0) {
|
|
8
|
-
const out = Object.entries(env.vars)
|
|
8
|
+
const out = Object.entries(env.vars)
|
|
9
|
+
.map(([k, v]) => `declare -x ${k}="${v}"`)
|
|
10
|
+
.join("\n");
|
|
9
11
|
return { stdout: out, exitCode: 0 };
|
|
10
12
|
}
|
|
11
13
|
for (const arg of args) {
|
package/dist/commands/find.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
|
+
/**
|
|
3
|
+
* Find files and directories by name and type with minimal pattern support.
|
|
4
|
+
* @category files
|
|
5
|
+
* @params ["[path] [-name <pattern>] [-type f|d]"]
|
|
6
|
+
*/
|
|
2
7
|
export declare const findCommand: ShellModule;
|
|
3
8
|
//# sourceMappingURL=find.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/commands/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,eAAO,MAAM,WAAW,EAAE,WA0DzB,CAAC"}
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/commands/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WA0DzB,CAAC"}
|
package/dist/commands/find.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { getFlag } from "./command-helpers";
|
|
2
2
|
import { assertPathAccess, resolvePath } from "./helpers";
|
|
3
|
+
/**
|
|
4
|
+
* Find files and directories by name and type with minimal pattern support.
|
|
5
|
+
* @category files
|
|
6
|
+
* @params ["[path] [-name <pattern>] [-type f|d]"]
|
|
7
|
+
*/
|
|
3
8
|
export const findCommand = {
|
|
4
9
|
name: "find",
|
|
5
10
|
description: "Search for files",
|
package/dist/commands/free.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
|
+
/**
|
|
3
|
+
* Display memory usage information (human / MB / GB options).
|
|
4
|
+
* @category system
|
|
5
|
+
* @params ["[-h] [-m] [-g]"]
|
|
6
|
+
*/
|
|
2
7
|
export declare const freeCommand: ShellModule;
|
|
3
8
|
//# sourceMappingURL=free.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"free.d.ts","sourceRoot":"","sources":["../../src/commands/free.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"free.d.ts","sourceRoot":"","sources":["../../src/commands/free.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAqCzB,CAAC"}
|
package/dist/commands/free.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as os from "node:os";
|
|
2
2
|
import { ifFlag } from "./command-helpers";
|
|
3
|
+
/**
|
|
4
|
+
* Display memory usage information (human / MB / GB options).
|
|
5
|
+
* @category system
|
|
6
|
+
* @params ["[-h] [-m] [-g]"]
|
|
7
|
+
*/
|
|
3
8
|
export const freeCommand = {
|
|
4
9
|
name: "free",
|
|
5
10
|
description: "Display amount of free and used memory",
|
package/dist/commands/grep.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
|
+
/**
|
|
3
|
+
* Search for a regex pattern in files or stdin with common flags.
|
|
4
|
+
* @category text
|
|
5
|
+
* @params ["[-i] [-v] [-n] [-r] <pattern> [file...]"]
|
|
6
|
+
*/
|
|
2
7
|
export declare const grepCommand: ShellModule;
|
|
3
8
|
//# sourceMappingURL=grep.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/commands/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/commands/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WA6FzB,CAAC"}
|
package/dist/commands/grep.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { parseArgs } from "./command-helpers";
|
|
2
2
|
import { assertPathAccess, resolvePath } from "./helpers";
|
|
3
|
+
/**
|
|
4
|
+
* Search for a regex pattern in files or stdin with common flags.
|
|
5
|
+
* @category text
|
|
6
|
+
* @params ["[-i] [-v] [-n] [-r] <pattern> [file...]"]
|
|
7
|
+
*/
|
|
3
8
|
export const grepCommand = {
|
|
4
9
|
name: "grep",
|
|
5
10
|
description: "Search text patterns",
|
|
6
11
|
category: "text",
|
|
7
12
|
params: ["[-i] [-v] [-n] [-r] <pattern> [file...]"],
|
|
8
13
|
run: ({ authUser, shell, cwd, args, stdin }) => {
|
|
9
|
-
const { flags, positionals } = parseArgs(args, {
|
|
14
|
+
const { flags, positionals } = parseArgs(args, {
|
|
15
|
+
flags: ["-i", "-v", "-n", "-r"],
|
|
16
|
+
});
|
|
10
17
|
const caseInsensitive = flags.has("-i");
|
|
11
18
|
const invertMatch = flags.has("-v");
|
|
12
19
|
const showLineNumbers = flags.has("-n");
|
|
@@ -80,7 +87,10 @@ export const grepCommand = {
|
|
|
80
87
|
results.push(...matchLines(content, prefix));
|
|
81
88
|
}
|
|
82
89
|
catch {
|
|
83
|
-
return {
|
|
90
|
+
return {
|
|
91
|
+
stderr: `grep: ${file}: No such file or directory`,
|
|
92
|
+
exitCode: 1,
|
|
93
|
+
};
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
96
|
}
|
package/dist/commands/gzip.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
|
+
/**
|
|
3
|
+
* Compress files using gzip (stores in VFS as compressed content).
|
|
4
|
+
* @category archive
|
|
5
|
+
* @params ["<file>"]
|
|
6
|
+
*/
|
|
2
7
|
export declare const gzipCommand: ShellModule;
|
|
3
8
|
export declare const gunzipCommand: ShellModule;
|
|
4
9
|
//# sourceMappingURL=gzip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gzip.d.ts","sourceRoot":"","sources":["../../src/commands/gzip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"gzip.d.ts","sourceRoot":"","sources":["../../src/commands/gzip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAmBzB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAyB3B,CAAC"}
|
package/dist/commands/gzip.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { resolvePath } from "./helpers";
|
|
2
|
+
/**
|
|
3
|
+
* Compress files using gzip (stores in VFS as compressed content).
|
|
4
|
+
* @category archive
|
|
5
|
+
* @params ["<file>"]
|
|
6
|
+
*/
|
|
2
7
|
export const gzipCommand = {
|
|
3
8
|
name: "gzip",
|
|
4
9
|
description: "Compress files",
|
|
@@ -14,11 +19,19 @@ export const gzipCommand = {
|
|
|
14
19
|
return { exitCode: 0 };
|
|
15
20
|
}
|
|
16
21
|
catch {
|
|
17
|
-
return {
|
|
22
|
+
return {
|
|
23
|
+
stderr: `gzip: ${file}: No such file or directory`,
|
|
24
|
+
exitCode: 1,
|
|
25
|
+
};
|
|
18
26
|
}
|
|
19
27
|
},
|
|
20
28
|
};
|
|
21
29
|
export const gunzipCommand = {
|
|
30
|
+
/**
|
|
31
|
+
* Decompress gzip files (or zcat alias).
|
|
32
|
+
* @category archive
|
|
33
|
+
* @params ["<file>"]
|
|
34
|
+
*/
|
|
22
35
|
name: "gunzip",
|
|
23
36
|
description: "Decompress files",
|
|
24
37
|
category: "archive",
|
|
@@ -34,7 +47,10 @@ export const gunzipCommand = {
|
|
|
34
47
|
return { exitCode: 0 };
|
|
35
48
|
}
|
|
36
49
|
catch {
|
|
37
|
-
return {
|
|
50
|
+
return {
|
|
51
|
+
stderr: `gunzip: ${file}: No such file or directory`,
|
|
52
|
+
exitCode: 1,
|
|
53
|
+
};
|
|
38
54
|
}
|
|
39
55
|
},
|
|
40
56
|
};
|
package/dist/commands/head.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../src/commands/head.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,eAAO,MAAM,WAAW,EAAE,WAgCzB,CAAC"}
|
|
1
|
+
{"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../src/commands/head.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAgCzB,CAAC"}
|
package/dist/commands/head.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { getFlag } from "./command-helpers";
|
|
2
2
|
import { assertPathAccess, resolvePath } from "./helpers";
|
|
3
|
+
/**
|
|
4
|
+
* Output the first part of files or stdin (head).
|
|
5
|
+
* @category text
|
|
6
|
+
* @params ["[-n <lines>] [file...]"]
|
|
7
|
+
*/
|
|
3
8
|
export const headCommand = {
|
|
4
9
|
name: "head",
|
|
5
10
|
description: "Output first lines",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA6HrD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,MAAM,EAAE,GAAG,WAAW,CA0BxE"}
|
package/dist/commands/help.js
CHANGED
|
@@ -1,70 +1,123 @@
|
|
|
1
|
-
import { getCommandModulesPublic } from "./
|
|
2
|
-
|
|
1
|
+
import { getCommandModulesPublic } from "./registry";
|
|
2
|
+
// ─── category config ──────────────────────────────────────────────────────────
|
|
3
|
+
const CATEGORY_ORDER = [
|
|
4
|
+
"navigation",
|
|
5
|
+
"files",
|
|
6
|
+
"text",
|
|
7
|
+
"archive",
|
|
8
|
+
"system",
|
|
9
|
+
"package",
|
|
10
|
+
"network",
|
|
11
|
+
"shell",
|
|
12
|
+
"users",
|
|
13
|
+
"misc",
|
|
14
|
+
];
|
|
3
15
|
const CATEGORY_LABELS = {
|
|
4
16
|
navigation: "Navigation",
|
|
5
17
|
files: "Files & Filesystem",
|
|
6
18
|
text: "Text Processing",
|
|
7
19
|
archive: "Archive & Compression",
|
|
8
20
|
system: "System",
|
|
21
|
+
package: "Package Management",
|
|
9
22
|
network: "Network",
|
|
10
|
-
shell: "Shell",
|
|
23
|
+
shell: "Shell & Scripting",
|
|
11
24
|
users: "Users & Permissions",
|
|
12
25
|
misc: "Miscellaneous",
|
|
13
26
|
};
|
|
14
|
-
|
|
27
|
+
// ─── formatting helpers ───────────────────────────────────────────────────────
|
|
28
|
+
const BOLD = "\x1b[1m";
|
|
29
|
+
const RESET = "\x1b[0m";
|
|
30
|
+
const CYAN = "\x1b[36m";
|
|
31
|
+
const YLW = "\x1b[33m";
|
|
32
|
+
const DIM = "\x1b[2m";
|
|
33
|
+
const GREEN = "\x1b[32m";
|
|
34
|
+
function pad(s, n) {
|
|
15
35
|
return s.length >= n ? s : s + " ".repeat(n - s.length);
|
|
16
36
|
}
|
|
37
|
+
function formatCmdLine(mod) {
|
|
38
|
+
const aliases = mod.aliases?.length
|
|
39
|
+
? ` ${DIM}(${mod.aliases.join(", ")})${RESET}`
|
|
40
|
+
: "";
|
|
41
|
+
return ` ${CYAN}${pad(mod.name, 16)}${RESET}${aliases}${pad("", mod.aliases?.length ? 0 : 0)} ${mod.description ?? ""}`;
|
|
42
|
+
}
|
|
43
|
+
// ─── full grouped listing ─────────────────────────────────────────────────────
|
|
44
|
+
function renderFull(modules) {
|
|
45
|
+
const grouped = {};
|
|
46
|
+
for (const mod of modules) {
|
|
47
|
+
const cat = mod.category ?? "misc";
|
|
48
|
+
if (!grouped[cat])
|
|
49
|
+
grouped[cat] = [];
|
|
50
|
+
grouped[cat].push(mod);
|
|
51
|
+
}
|
|
52
|
+
const lines = [
|
|
53
|
+
`${BOLD}Available commands${RESET}`,
|
|
54
|
+
`${DIM}Type 'help <command>' for detailed usage.${RESET}`,
|
|
55
|
+
"",
|
|
56
|
+
];
|
|
57
|
+
const cats = [
|
|
58
|
+
...CATEGORY_ORDER.filter((c) => grouped[c]),
|
|
59
|
+
...Object.keys(grouped)
|
|
60
|
+
.filter((c) => !CATEGORY_ORDER.includes(c))
|
|
61
|
+
.sort(),
|
|
62
|
+
];
|
|
63
|
+
for (const cat of cats) {
|
|
64
|
+
const mods = grouped[cat];
|
|
65
|
+
if (!mods?.length)
|
|
66
|
+
continue;
|
|
67
|
+
lines.push(`${YLW}${CATEGORY_LABELS[cat] ?? cat}${RESET}`);
|
|
68
|
+
const sorted = [...mods].sort((a, b) => a.name.localeCompare(b.name));
|
|
69
|
+
for (const mod of sorted) {
|
|
70
|
+
lines.push(formatCmdLine(mod));
|
|
71
|
+
}
|
|
72
|
+
lines.push("");
|
|
73
|
+
}
|
|
74
|
+
const total = modules.length;
|
|
75
|
+
lines.push(`${DIM}${total} commands available.${RESET}`);
|
|
76
|
+
return lines.join("\n");
|
|
77
|
+
}
|
|
78
|
+
// ─── single-command detail ────────────────────────────────────────────────────
|
|
79
|
+
function renderDetail(mod) {
|
|
80
|
+
const lines = [];
|
|
81
|
+
lines.push(`${BOLD}${mod.name}${RESET} — ${mod.description ?? "no description"}`);
|
|
82
|
+
if (mod.aliases?.length) {
|
|
83
|
+
lines.push(`${DIM}Aliases: ${mod.aliases.join(", ")}${RESET}`);
|
|
84
|
+
}
|
|
85
|
+
lines.push("");
|
|
86
|
+
lines.push(`${GREEN}Usage:${RESET}`);
|
|
87
|
+
if (mod.params.length) {
|
|
88
|
+
for (const p of mod.params) {
|
|
89
|
+
lines.push(` ${mod.name} ${p}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
lines.push(` ${mod.name}`);
|
|
94
|
+
}
|
|
95
|
+
const catLabel = CATEGORY_LABELS[mod.category ?? "misc"] ?? mod.category ?? "misc";
|
|
96
|
+
lines.push("");
|
|
97
|
+
lines.push(`${DIM}Category: ${catLabel}${RESET}`);
|
|
98
|
+
return lines.join("\n");
|
|
99
|
+
}
|
|
100
|
+
// ─── export ───────────────────────────────────────────────────────────────────
|
|
17
101
|
export function createHelpCommand(_getNames) {
|
|
18
102
|
return {
|
|
19
103
|
name: "help",
|
|
20
|
-
description: "
|
|
104
|
+
description: "List all commands, or show usage for a specific command",
|
|
21
105
|
category: "shell",
|
|
22
106
|
params: ["[command]"],
|
|
23
107
|
run: ({ args }) => {
|
|
24
108
|
const modules = getCommandModulesPublic();
|
|
25
|
-
// help <command>
|
|
26
109
|
if (args[0]) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`\x1b[1m${mod.name}\x1b[0m — ${mod.description ?? "no description"}`,
|
|
35
|
-
aliases,
|
|
36
|
-
"Usage:",
|
|
37
|
-
params || ` ${mod.name}`,
|
|
38
|
-
].filter(Boolean).join("\n"),
|
|
39
|
-
exitCode: 0,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
// Full help — grouped by category
|
|
43
|
-
const grouped = {};
|
|
44
|
-
for (const mod of modules) {
|
|
45
|
-
const cat = mod.category ?? "misc";
|
|
46
|
-
if (!grouped[cat])
|
|
47
|
-
grouped[cat] = [];
|
|
48
|
-
grouped[cat].push(mod);
|
|
49
|
-
}
|
|
50
|
-
const lines = [];
|
|
51
|
-
lines.push("\x1b[1mAvailable commands\x1b[0m");
|
|
52
|
-
lines.push("");
|
|
53
|
-
const cats = [
|
|
54
|
-
...CATEGORY_ORDER.filter((c) => grouped[c]),
|
|
55
|
-
...Object.keys(grouped).filter((c) => !CATEGORY_ORDER.includes(c)),
|
|
56
|
-
];
|
|
57
|
-
for (const cat of cats) {
|
|
58
|
-
const mods = grouped[cat];
|
|
59
|
-
if (!mods || mods.length === 0)
|
|
60
|
-
continue;
|
|
61
|
-
lines.push(`\x1b[33m${CATEGORY_LABELS[cat] ?? cat}\x1b[0m`);
|
|
62
|
-
const sorted = [...mods].sort((a, b) => a.name.localeCompare(b.name));
|
|
63
|
-
for (const mod of sorted) {
|
|
64
|
-
lines.push(` \x1b[36m${padRight(mod.name, 14)}\x1b[0m ${mod.description ?? ""}`);
|
|
110
|
+
const target = args[0].toLowerCase();
|
|
111
|
+
const mod = modules.find((m) => m.name === target || m.aliases?.includes(target));
|
|
112
|
+
if (!mod) {
|
|
113
|
+
return {
|
|
114
|
+
stderr: `help: no help entry for '${args[0]}'`,
|
|
115
|
+
exitCode: 1,
|
|
116
|
+
};
|
|
65
117
|
}
|
|
118
|
+
return { stdout: renderDetail(mod), exitCode: 0 };
|
|
66
119
|
}
|
|
67
|
-
return { stdout:
|
|
120
|
+
return { stdout: renderFull(modules), exitCode: 0 };
|
|
68
121
|
},
|
|
69
122
|
};
|
|
70
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,cAAc,EAAE,WA0B5B,CAAC"}
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,WA0B5B,CAAC"}
|