@fnndsc/chell 4.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +325 -0
- package/dist/builtins/debug.d.ts +6 -0
- package/dist/builtins/debug.js +47 -0
- package/dist/builtins/debug.js.map +1 -0
- package/dist/builtins/executable.d.ts +22 -0
- package/dist/builtins/executable.js +115 -0
- package/dist/builtins/executable.js.map +1 -0
- package/dist/builtins/fs/cat.d.ts +16 -0
- package/dist/builtins/fs/cat.js +249 -0
- package/dist/builtins/fs/cat.js.map +1 -0
- package/dist/builtins/fs/cd.d.ts +41 -0
- package/dist/builtins/fs/cd.js +178 -0
- package/dist/builtins/fs/cd.js.map +1 -0
- package/dist/builtins/fs/cp.d.ts +7 -0
- package/dist/builtins/fs/cp.js +73 -0
- package/dist/builtins/fs/cp.js.map +1 -0
- package/dist/builtins/fs/download.d.ts +6 -0
- package/dist/builtins/fs/download.js +41 -0
- package/dist/builtins/fs/download.js.map +1 -0
- package/dist/builtins/fs/du.d.ts +58 -0
- package/dist/builtins/fs/du.js +210 -0
- package/dist/builtins/fs/du.js.map +1 -0
- package/dist/builtins/fs/edit.d.ts +7 -0
- package/dist/builtins/fs/edit.js +86 -0
- package/dist/builtins/fs/edit.js.map +1 -0
- package/dist/builtins/fs/ls.d.ts +8 -0
- package/dist/builtins/fs/ls.js +68 -0
- package/dist/builtins/fs/ls.js.map +1 -0
- package/dist/builtins/fs/mkdir.d.ts +6 -0
- package/dist/builtins/fs/mkdir.js +38 -0
- package/dist/builtins/fs/mkdir.js.map +1 -0
- package/dist/builtins/fs/mv.d.ts +7 -0
- package/dist/builtins/fs/mv.js +75 -0
- package/dist/builtins/fs/mv.js.map +1 -0
- package/dist/builtins/fs/pull.args.d.ts +22 -0
- package/dist/builtins/fs/pull.args.js +30 -0
- package/dist/builtins/fs/pull.args.js.map +1 -0
- package/dist/builtins/fs/pull.d.ts +26 -0
- package/dist/builtins/fs/pull.js +413 -0
- package/dist/builtins/fs/pull.js.map +1 -0
- package/dist/builtins/fs/pwd.d.ts +7 -0
- package/dist/builtins/fs/pwd.js +75 -0
- package/dist/builtins/fs/pwd.js.map +1 -0
- package/dist/builtins/fs/rm.d.ts +31 -0
- package/dist/builtins/fs/rm.js +148 -0
- package/dist/builtins/fs/rm.js.map +1 -0
- package/dist/builtins/fs/touch.d.ts +6 -0
- package/dist/builtins/fs/touch.js +64 -0
- package/dist/builtins/fs/touch.js.map +1 -0
- package/dist/builtins/fs/tree.d.ts +15 -0
- package/dist/builtins/fs/tree.js +84 -0
- package/dist/builtins/fs/tree.js.map +1 -0
- package/dist/builtins/fs/upload.d.ts +6 -0
- package/dist/builtins/fs/upload.js +45 -0
- package/dist/builtins/fs/upload.js.map +1 -0
- package/dist/builtins/help.d.ts +74 -0
- package/dist/builtins/help.js +1217 -0
- package/dist/builtins/help.js.map +1 -0
- package/dist/builtins/index.d.ts +45 -0
- package/dist/builtins/index.js +45 -0
- package/dist/builtins/index.js.map +1 -0
- package/dist/builtins/net/connect.d.ts +7 -0
- package/dist/builtins/net/connect.js +42 -0
- package/dist/builtins/net/connect.js.map +1 -0
- package/dist/builtins/net/cubepath.d.ts +18 -0
- package/dist/builtins/net/cubepath.js +102 -0
- package/dist/builtins/net/cubepath.js.map +1 -0
- package/dist/builtins/net/logout.d.ts +6 -0
- package/dist/builtins/net/logout.js +24 -0
- package/dist/builtins/net/logout.js.map +1 -0
- package/dist/builtins/net/pacs.d.ts +24 -0
- package/dist/builtins/net/pacs.js +121 -0
- package/dist/builtins/net/pacs.js.map +1 -0
- package/dist/builtins/net/pacsUtils.d.ts +85 -0
- package/dist/builtins/net/pacsUtils.js +184 -0
- package/dist/builtins/net/pacsUtils.js.map +1 -0
- package/dist/builtins/net/query.d.ts +60 -0
- package/dist/builtins/net/query.js +304 -0
- package/dist/builtins/net/query.js.map +1 -0
- package/dist/builtins/parametersofplugin.d.ts +13 -0
- package/dist/builtins/parametersofplugin.js +43 -0
- package/dist/builtins/parametersofplugin.js.map +1 -0
- package/dist/builtins/pluginExecute.d.ts +27 -0
- package/dist/builtins/pluginExecute.js +165 -0
- package/dist/builtins/pluginExecute.js.map +1 -0
- package/dist/builtins/proc.d.ts +6 -0
- package/dist/builtins/proc.helpers.d.ts +68 -0
- package/dist/builtins/proc.helpers.js +102 -0
- package/dist/builtins/proc.helpers.js.map +1 -0
- package/dist/builtins/proc.js +289 -0
- package/dist/builtins/proc.js.map +1 -0
- package/dist/builtins/res/compute.d.ts +6 -0
- package/dist/builtins/res/compute.js +55 -0
- package/dist/builtins/res/compute.js.map +1 -0
- package/dist/builtins/res/feed.d.ts +6 -0
- package/dist/builtins/res/feed.js +244 -0
- package/dist/builtins/res/feed.js.map +1 -0
- package/dist/builtins/res/feed.notes.d.ts +28 -0
- package/dist/builtins/res/feed.notes.js +24 -0
- package/dist/builtins/res/feed.notes.js.map +1 -0
- package/dist/builtins/res/files.d.ts +18 -0
- package/dist/builtins/res/files.js +85 -0
- package/dist/builtins/res/files.js.map +1 -0
- package/dist/builtins/res/group.d.ts +6 -0
- package/dist/builtins/res/group.js +54 -0
- package/dist/builtins/res/group.js.map +1 -0
- package/dist/builtins/res/pipeline.args.d.ts +22 -0
- package/dist/builtins/res/pipeline.args.js +28 -0
- package/dist/builtins/res/pipeline.args.js.map +1 -0
- package/dist/builtins/res/pipeline.d.ts +20 -0
- package/dist/builtins/res/pipeline.js +252 -0
- package/dist/builtins/res/pipeline.js.map +1 -0
- package/dist/builtins/res/plugin.d.ts +13 -0
- package/dist/builtins/res/plugin.js +140 -0
- package/dist/builtins/res/plugin.js.map +1 -0
- package/dist/builtins/res/plugininstance.d.ts +6 -0
- package/dist/builtins/res/plugininstance.js +53 -0
- package/dist/builtins/res/plugininstance.js.map +1 -0
- package/dist/builtins/res/pluginmeta.d.ts +6 -0
- package/dist/builtins/res/pluginmeta.js +53 -0
- package/dist/builtins/res/pluginmeta.js.map +1 -0
- package/dist/builtins/res/tag.d.ts +6 -0
- package/dist/builtins/res/tag.js +53 -0
- package/dist/builtins/res/tag.js.map +1 -0
- package/dist/builtins/res/workflow.d.ts +6 -0
- package/dist/builtins/res/workflow.js +53 -0
- package/dist/builtins/res/workflow.js.map +1 -0
- package/dist/builtins/store.d.ts +6 -0
- package/dist/builtins/store.js +108 -0
- package/dist/builtins/store.js.map +1 -0
- package/dist/builtins/sys/context.d.ts +6 -0
- package/dist/builtins/sys/context.js +50 -0
- package/dist/builtins/sys/context.js.map +1 -0
- package/dist/builtins/sys/physicalmode.d.ts +6 -0
- package/dist/builtins/sys/physicalmode.js +41 -0
- package/dist/builtins/sys/physicalmode.js.map +1 -0
- package/dist/builtins/sys/prompt.d.ts +13 -0
- package/dist/builtins/sys/prompt.helpers.d.ts +31 -0
- package/dist/builtins/sys/prompt.helpers.js +36 -0
- package/dist/builtins/sys/prompt.helpers.js.map +1 -0
- package/dist/builtins/sys/prompt.js +182 -0
- package/dist/builtins/sys/prompt.js.map +1 -0
- package/dist/builtins/sys/timing.d.ts +6 -0
- package/dist/builtins/sys/timing.js +41 -0
- package/dist/builtins/sys/timing.js.map +1 -0
- package/dist/builtins/sys/whoami.d.ts +12 -0
- package/dist/builtins/sys/whoami.js +37 -0
- package/dist/builtins/sys/whoami.js.map +1 -0
- package/dist/builtins/utils.d.ts +55 -0
- package/dist/builtins/utils.js +145 -0
- package/dist/builtins/utils.js.map +1 -0
- package/dist/builtins/wildcard.d.ts +26 -0
- package/dist/builtins/wildcard.js +120 -0
- package/dist/builtins/wildcard.js.map +1 -0
- package/dist/chell.d.ts +16 -0
- package/dist/chell.js +1193 -0
- package/dist/chell.js.map +1 -0
- package/dist/command-keys.d.ts +8 -0
- package/dist/command-keys.js +32 -0
- package/dist/command-keys.js.map +1 -0
- package/dist/config/settings.d.ts +39 -0
- package/dist/config/settings.js +93 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/core/bootFlags.d.ts +32 -0
- package/dist/core/bootFlags.js +25 -0
- package/dist/core/bootFlags.js.map +1 -0
- package/dist/core/cli.d.ts +58 -0
- package/dist/core/cli.js +251 -0
- package/dist/core/cli.js.map +1 -0
- package/dist/core/prompt/index.d.ts +80 -0
- package/dist/core/prompt/index.js +29 -0
- package/dist/core/prompt/index.js.map +1 -0
- package/dist/core/prompt/theme_default.d.ts +19 -0
- package/dist/core/prompt/theme_default.js +47 -0
- package/dist/core/prompt/theme_default.js.map +1 -0
- package/dist/core/prompt/theme_p10k.d.ts +22 -0
- package/dist/core/prompt/theme_p10k.js +164 -0
- package/dist/core/prompt/theme_p10k.js.map +1 -0
- package/dist/core/prompt/utils.d.ts +23 -0
- package/dist/core/prompt/utils.js +40 -0
- package/dist/core/prompt/utils.js.map +1 -0
- package/dist/core/question.d.ts +34 -0
- package/dist/core/question.js +76 -0
- package/dist/core/question.js.map +1 -0
- package/dist/core/repl.d.ts +31 -0
- package/dist/core/repl.js +146 -0
- package/dist/core/repl.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/bootsequence.d.ts +62 -0
- package/dist/lib/bootsequence.js +222 -0
- package/dist/lib/bootsequence.js.map +1 -0
- package/dist/lib/completer/index.d.ts +15 -0
- package/dist/lib/completer/index.js +212 -0
- package/dist/lib/completer/index.js.map +1 -0
- package/dist/lib/completer/pathComplete.helpers.d.ts +22 -0
- package/dist/lib/completer/pathComplete.helpers.js +49 -0
- package/dist/lib/completer/pathComplete.helpers.js.map +1 -0
- package/dist/lib/logo.d.ts +47 -0
- package/dist/lib/logo.js +313 -0
- package/dist/lib/logo.js.map +1 -0
- package/dist/lib/parser.d.ts +13 -0
- package/dist/lib/parser.js +52 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/pipe.d.ts +11 -0
- package/dist/lib/pipe.js +90 -0
- package/dist/lib/pipe.js.map +1 -0
- package/dist/lib/prefetch.d.ts +25 -0
- package/dist/lib/prefetch.js +64 -0
- package/dist/lib/prefetch.js.map +1 -0
- package/dist/lib/semicolonParser.d.ts +22 -0
- package/dist/lib/semicolonParser.js +53 -0
- package/dist/lib/semicolonParser.js.map +1 -0
- package/dist/lib/spinner.d.ts +23 -0
- package/dist/lib/spinner.js +68 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/vfs/providers/static.d.ts +65 -0
- package/dist/lib/vfs/providers/static.js +164 -0
- package/dist/lib/vfs/providers/static.js.map +1 -0
- package/dist/lib/vfs/providers/static_content.d.ts +27 -0
- package/dist/lib/vfs/providers/static_content.js +180 -0
- package/dist/lib/vfs/providers/static_content.js.map +1 -0
- package/dist/lib/vfs/vfs.d.ts +59 -0
- package/dist/lib/vfs/vfs.js +198 -0
- package/dist/lib/vfs/vfs.js.map +1 -0
- package/dist/session/index.d.ts +76 -0
- package/dist/session/index.js +120 -0
- package/dist/session/index.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Builtin timing command.
|
|
3
|
+
* Toggles execution timing.
|
|
4
|
+
*/
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { session } from '../../session/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Toggles or displays command timing mode.
|
|
9
|
+
*
|
|
10
|
+
* @param args - Command line arguments: 'on', 'off', or empty to display status.
|
|
11
|
+
*/
|
|
12
|
+
export async function builtin_timing(args) {
|
|
13
|
+
const subcommand = args[0];
|
|
14
|
+
if (!subcommand) {
|
|
15
|
+
const status = session.timingEnabled_get() ? 'enabled' : 'disabled';
|
|
16
|
+
console.log(`Command timing: ${chalk.yellow(status)}`);
|
|
17
|
+
if (session.timingEnabled_get()) {
|
|
18
|
+
console.log(chalk.gray(' Execution times will be displayed after each command.'));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.log(chalk.gray(' Execution times are hidden.'));
|
|
22
|
+
}
|
|
23
|
+
console.log(chalk.gray('\nUsage: timing [on|off]'));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (subcommand === 'on') {
|
|
27
|
+
session.timingEnabled_set(true);
|
|
28
|
+
console.log(chalk.green('[+] Command timing enabled'));
|
|
29
|
+
console.log(chalk.gray(' Execution times will be displayed after each command.'));
|
|
30
|
+
}
|
|
31
|
+
else if (subcommand === 'off') {
|
|
32
|
+
session.timingEnabled_set(false);
|
|
33
|
+
console.log(chalk.gray('[-] Command timing disabled'));
|
|
34
|
+
console.log(chalk.gray(' Execution times will no longer be displayed.'));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.log(chalk.red(`Unknown argument: ${subcommand}`));
|
|
38
|
+
console.log(chalk.gray('Usage: timing [on|off]'));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=timing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../../src/builtins/sys/timing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAc;IACjD,MAAM,UAAU,GAAuB,IAAI,CAAC,CAAC,CAAC,CAAC;IAE/C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,MAAM,GAAW,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACvD,IAAI,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC,CAAC;QACrF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC;QACpD,OAAO;IACT,CAAC;IAED,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC,CAAC;IACvF,CAAC;SAAM,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QAChC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC,CAAC;IAC9E,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prints the current authenticated ChRIS username.
|
|
3
|
+
*
|
|
4
|
+
* @param _args - Unused.
|
|
5
|
+
*/
|
|
6
|
+
export declare function builtin_whoami(_args: string[]): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Prints the current CUBE URI.
|
|
9
|
+
*
|
|
10
|
+
* @param _args - Unused.
|
|
11
|
+
*/
|
|
12
|
+
export declare function builtin_whereami(_args: string[]): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Builtins whoami and whereami.
|
|
3
|
+
* Quick single-line identity queries.
|
|
4
|
+
*/
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { context_getSingle } from '@fnndsc/salsa';
|
|
7
|
+
/**
|
|
8
|
+
* Prints the current authenticated ChRIS username.
|
|
9
|
+
*
|
|
10
|
+
* @param _args - Unused.
|
|
11
|
+
*/
|
|
12
|
+
export async function builtin_whoami(_args) {
|
|
13
|
+
const context = await context_getSingle();
|
|
14
|
+
if (context.user) {
|
|
15
|
+
console.log(chalk.cyan(context.user));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.log(chalk.gray('(not connected)'));
|
|
19
|
+
process.exitCode = 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Prints the current CUBE URI.
|
|
24
|
+
*
|
|
25
|
+
* @param _args - Unused.
|
|
26
|
+
*/
|
|
27
|
+
export async function builtin_whereami(_args) {
|
|
28
|
+
const context = await context_getSingle();
|
|
29
|
+
if (context.URL) {
|
|
30
|
+
console.log(chalk.blue(context.URL));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.log(chalk.gray('(not connected)'));
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../src/builtins/sys/whoami.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAAe;IAClD,MAAM,OAAO,GAAkB,MAAM,iBAAiB,EAAE,CAAC;IACzD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAC3C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAe;IACpD,MAAM,OAAO,GAAkB,MAAM,iBAAiB,EAAE,CAAC;IACzD,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAC3C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structure for parsed command line arguments.
|
|
3
|
+
*/
|
|
4
|
+
export interface ParsedArgs {
|
|
5
|
+
_: string[];
|
|
6
|
+
[key: string]: string | boolean | string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parses raw argument strings into a structured object.
|
|
10
|
+
* Supports `--` as an end-of-options marker (everything after is treated as positional args).
|
|
11
|
+
*/
|
|
12
|
+
export declare function commandArgs_process(args: string[]): ParsedArgs;
|
|
13
|
+
/**
|
|
14
|
+
* Context required for path resolution.
|
|
15
|
+
*/
|
|
16
|
+
export interface PathContext {
|
|
17
|
+
user: string | null;
|
|
18
|
+
cwd: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolves a path argument, handling `~` expansion and relative paths.
|
|
22
|
+
* Pure function version that takes context as argument.
|
|
23
|
+
*
|
|
24
|
+
* @param inputPath - The path to resolve.
|
|
25
|
+
* @param context - User and CWD context.
|
|
26
|
+
* @returns The absolute path.
|
|
27
|
+
*/
|
|
28
|
+
export declare function path_resolvePure(inputPath: string, context: PathContext): string;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves a path argument, handling `~` expansion and relative paths.
|
|
31
|
+
* @param inputPath - The path to resolve.
|
|
32
|
+
* @returns The absolute path.
|
|
33
|
+
*/
|
|
34
|
+
export declare function path_resolve(inputPath: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Resolves links in a path without using PathMapper (for physical mode).
|
|
37
|
+
* Checks each component to see if it's a link and follows it.
|
|
38
|
+
*
|
|
39
|
+
* @param targetPath - The path to resolve.
|
|
40
|
+
* @returns The resolved path with links followed.
|
|
41
|
+
*/
|
|
42
|
+
export declare function path_resolveLinks(targetPath: string): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Strips the function name padding prefix from an error message if debug mode is disabled.
|
|
45
|
+
*
|
|
46
|
+
* @param message - The raw/enhanced error message from the ErrorStack.
|
|
47
|
+
* @returns The cleaned or original error message based on the debug configuration.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```
|
|
51
|
+
* const cleaned = error_stripDebugPrefix("[PacsVfsProvider.list ] | ls: error");
|
|
52
|
+
* // cleaned will be "ls: error" if debug mode is disabled
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function error_stripDebugPrefix(message: string): string;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Builtin Utilities
|
|
3
|
+
* Pure functions for argument parsing and path resolution logic.
|
|
4
|
+
*/
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { context_getSingle } from '@fnndsc/salsa';
|
|
7
|
+
import { session } from '../session/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Parses raw argument strings into a structured object.
|
|
10
|
+
* Supports `--` as an end-of-options marker (everything after is treated as positional args).
|
|
11
|
+
*/
|
|
12
|
+
export function commandArgs_process(args) {
|
|
13
|
+
const result = { _: [] };
|
|
14
|
+
let endOfOptions = false;
|
|
15
|
+
for (let i = 0; i < args.length; i++) {
|
|
16
|
+
const arg = args[i];
|
|
17
|
+
// Check for -- (end of options marker)
|
|
18
|
+
if (arg === '--') {
|
|
19
|
+
endOfOptions = true;
|
|
20
|
+
continue; // Skip the -- itself
|
|
21
|
+
}
|
|
22
|
+
// After --, everything is a positional argument
|
|
23
|
+
if (endOfOptions) {
|
|
24
|
+
result._.push(arg);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (arg.startsWith('--')) {
|
|
28
|
+
const key = arg.substring(2);
|
|
29
|
+
if (args[i + 1] && !args[i + 1].startsWith('-')) {
|
|
30
|
+
result[key] = args[i + 1];
|
|
31
|
+
i++;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
result[key] = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (arg.startsWith('-') && arg.length > 1) {
|
|
38
|
+
const flags = arg.substring(1).split('');
|
|
39
|
+
flags.forEach(flag => result[flag] = true);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
result._.push(arg);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resolves a path argument, handling `~` expansion and relative paths.
|
|
49
|
+
* Pure function version that takes context as argument.
|
|
50
|
+
*
|
|
51
|
+
* @param inputPath - The path to resolve.
|
|
52
|
+
* @param context - User and CWD context.
|
|
53
|
+
* @returns The absolute path.
|
|
54
|
+
*/
|
|
55
|
+
export function path_resolvePure(inputPath, context) {
|
|
56
|
+
let resolved = inputPath;
|
|
57
|
+
const { user, cwd } = context;
|
|
58
|
+
if (inputPath.startsWith('~')) {
|
|
59
|
+
const home = user ? `/home/${user}` : '/';
|
|
60
|
+
if (inputPath === '~' || inputPath === '~/') {
|
|
61
|
+
resolved = home;
|
|
62
|
+
}
|
|
63
|
+
else if (inputPath.startsWith('~/')) {
|
|
64
|
+
resolved = path.posix.join(home, inputPath.substring(2));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!resolved.startsWith('/')) {
|
|
68
|
+
resolved = path.posix.resolve(cwd, resolved);
|
|
69
|
+
}
|
|
70
|
+
// Normalize
|
|
71
|
+
if (resolved.length > 1 && resolved.endsWith('/')) {
|
|
72
|
+
resolved = resolved.slice(0, -1);
|
|
73
|
+
}
|
|
74
|
+
return resolved;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolves a path argument, handling `~` expansion and relative paths.
|
|
78
|
+
* @param inputPath - The path to resolve.
|
|
79
|
+
* @returns The absolute path.
|
|
80
|
+
*/
|
|
81
|
+
export async function path_resolve(inputPath) {
|
|
82
|
+
const context = await context_getSingle();
|
|
83
|
+
const user = context.user;
|
|
84
|
+
const cwd = await session.getCWD();
|
|
85
|
+
return path_resolvePure(inputPath, { user, cwd });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolves links in a path without using PathMapper (for physical mode).
|
|
89
|
+
* Checks each component to see if it's a link and follows it.
|
|
90
|
+
*
|
|
91
|
+
* @param targetPath - The path to resolve.
|
|
92
|
+
* @returns The resolved path with links followed.
|
|
93
|
+
*/
|
|
94
|
+
export async function path_resolveLinks(targetPath) {
|
|
95
|
+
// We need to dynamically import files_list to avoid circular dependency
|
|
96
|
+
// because builtins/fs/ls.ts imports path_resolve from here
|
|
97
|
+
const { files_list } = await import('@fnndsc/chili/commands/fs/ls.js');
|
|
98
|
+
const components = targetPath.split('/').filter(c => c);
|
|
99
|
+
let currentPath = '';
|
|
100
|
+
for (const component of components) {
|
|
101
|
+
const parentPath = currentPath || '/';
|
|
102
|
+
currentPath = `${currentPath}/${component}`;
|
|
103
|
+
try {
|
|
104
|
+
// List parent directory to check if component is a link
|
|
105
|
+
const items = await files_list({ path: parentPath }, parentPath);
|
|
106
|
+
// Find the component in the listing
|
|
107
|
+
const item = items.find((i) => i.name === component);
|
|
108
|
+
if (item && item.type === 'link' && item.target) {
|
|
109
|
+
// Component is a link - resolve it
|
|
110
|
+
if (item.target.startsWith('/')) {
|
|
111
|
+
// Absolute link target
|
|
112
|
+
currentPath = item.target;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Relative link target
|
|
116
|
+
currentPath = `${parentPath}/${item.target}`.replace('//', '/');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (_error) {
|
|
121
|
+
// If we can't list the directory, continue with the current path
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return currentPath || '/';
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Strips the function name padding prefix from an error message if debug mode is disabled.
|
|
129
|
+
*
|
|
130
|
+
* @param message - The raw/enhanced error message from the ErrorStack.
|
|
131
|
+
* @returns The cleaned or original error message based on the debug configuration.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```
|
|
135
|
+
* const cleaned = error_stripDebugPrefix("[PacsVfsProvider.list ] | ls: error");
|
|
136
|
+
* // cleaned will be "ls: error" if debug mode is disabled
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export function error_stripDebugPrefix(message) {
|
|
140
|
+
if (session.connection?.config?.debug) {
|
|
141
|
+
return message;
|
|
142
|
+
}
|
|
143
|
+
return message.replace(/^\[[^\]]+\]\s*\|\s*/, '');
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/builtins/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MA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I,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChD,mCAAmC;gBACnC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBAChC,uBAAuB;oBACvB,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;gBAC5B,CAAC;qBAAM,CAAC;oBACN,uBAAuB;oBACvB,WAAW,GAAG,GAAG,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,MAAe,EAAE,CAAC;YACzB,iEAAiE;YACjE,SAAS;QACX,CAAC;IACH,CAAC;IAED,OAAO,WAAW,IAAI,GAAG,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,IAAI,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACtC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Result } from '@fnndsc/cumin';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a string contains wildcard characters.
|
|
4
|
+
*
|
|
5
|
+
* @param arg - The argument to check.
|
|
6
|
+
* @returns True if the argument contains wildcards.
|
|
7
|
+
*/
|
|
8
|
+
export declare function string_checkHasWildcard(arg: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Expands a wildcard pattern against the current directory.
|
|
11
|
+
*
|
|
12
|
+
* @param pattern - The glob pattern (e.g., "*.ts", "test*.json").
|
|
13
|
+
* @returns A Promise resolving to Result<string[]>.
|
|
14
|
+
* Ok([]) = no matches (not an error).
|
|
15
|
+
* Err(...) = couldn't expand (API failure, permission denied, etc.).
|
|
16
|
+
*/
|
|
17
|
+
export declare function wildcard_expand(pattern: string): Promise<Result<string[]>>;
|
|
18
|
+
/**
|
|
19
|
+
* Expands all wildcards in an argument list.
|
|
20
|
+
*
|
|
21
|
+
* @param args - The argument list potentially containing wildcards.
|
|
22
|
+
* @returns A Promise resolving to Result<string[]>.
|
|
23
|
+
* On error expanding any pattern, returns the error.
|
|
24
|
+
* Empty matches return the original pattern.
|
|
25
|
+
*/
|
|
26
|
+
export declare function wildcards_expandAll(args: string[]): Promise<Result<string[]>>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Wildcard expansion for shell commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides glob pattern matching against the ChRIS filesystem.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { minimatch } from 'minimatch';
|
|
9
|
+
import { session } from '../session/index.js';
|
|
10
|
+
import { vfsDispatcher } from '@fnndsc/salsa';
|
|
11
|
+
import { listCache_get, Ok, Err, errorStack } from '@fnndsc/cumin';
|
|
12
|
+
/**
|
|
13
|
+
* Checks if a string contains wildcard characters.
|
|
14
|
+
*
|
|
15
|
+
* @param arg - The argument to check.
|
|
16
|
+
* @returns True if the argument contains wildcards.
|
|
17
|
+
*/
|
|
18
|
+
export function string_checkHasWildcard(arg) {
|
|
19
|
+
return /[*?[\]]/.test(arg);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Expands a wildcard pattern against the current directory.
|
|
23
|
+
*
|
|
24
|
+
* @param pattern - The glob pattern (e.g., "*.ts", "test*.json").
|
|
25
|
+
* @returns A Promise resolving to Result<string[]>.
|
|
26
|
+
* Ok([]) = no matches (not an error).
|
|
27
|
+
* Err(...) = couldn't expand (API failure, permission denied, etc.).
|
|
28
|
+
*/
|
|
29
|
+
export async function wildcard_expand(pattern) {
|
|
30
|
+
// If no wildcard, return as-is
|
|
31
|
+
if (!string_checkHasWildcard(pattern)) {
|
|
32
|
+
return Ok([pattern]);
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
// Get current directory
|
|
36
|
+
const cwd = await session.getCWD();
|
|
37
|
+
// Handle patterns with directory components (e.g., "data/*.txt")
|
|
38
|
+
let searchDir = cwd;
|
|
39
|
+
let matchPattern = pattern;
|
|
40
|
+
// Check if pattern has directory separator
|
|
41
|
+
if (pattern.includes('/')) {
|
|
42
|
+
const parts = pattern.split('/');
|
|
43
|
+
const lastPart = parts.pop() || '*';
|
|
44
|
+
const dirPart = parts.join('/');
|
|
45
|
+
// Resolve directory part (could be relative)
|
|
46
|
+
if (dirPart.startsWith('/')) {
|
|
47
|
+
searchDir = dirPart;
|
|
48
|
+
}
|
|
49
|
+
else if (dirPart === '.') {
|
|
50
|
+
searchDir = cwd;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// Relative path - append to cwd
|
|
54
|
+
searchDir = `${cwd}/${dirPart}`.replace(/\/+/g, '/');
|
|
55
|
+
}
|
|
56
|
+
matchPattern = lastPart;
|
|
57
|
+
}
|
|
58
|
+
// List files in the directory (check cache first)
|
|
59
|
+
let items = [];
|
|
60
|
+
const listCache = listCache_get();
|
|
61
|
+
const cached = listCache.cache_get(searchDir);
|
|
62
|
+
if (cached) {
|
|
63
|
+
items = cached.data;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const vfsResult = await vfsDispatcher.list(searchDir);
|
|
67
|
+
if (vfsResult.ok) {
|
|
68
|
+
items = vfsResult.value;
|
|
69
|
+
listCache.cache_set(searchDir, items);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return Err();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Filter items by pattern
|
|
76
|
+
const matches = items
|
|
77
|
+
.filter((item) => minimatch(item.name, matchPattern))
|
|
78
|
+
.map((item) => {
|
|
79
|
+
// Return full path if we searched a different directory
|
|
80
|
+
if (searchDir !== cwd) {
|
|
81
|
+
return `${searchDir}/${item.name}`.replace(/\/+/g, '/');
|
|
82
|
+
}
|
|
83
|
+
return item.name;
|
|
84
|
+
});
|
|
85
|
+
// Ok([]) for no matches (not an error)
|
|
86
|
+
return Ok(matches);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
90
|
+
errorStack.stack_push("error", `Failed to expand wildcard '${pattern}': ${errorMsg}`);
|
|
91
|
+
return Err();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Expands all wildcards in an argument list.
|
|
96
|
+
*
|
|
97
|
+
* @param args - The argument list potentially containing wildcards.
|
|
98
|
+
* @returns A Promise resolving to Result<string[]>.
|
|
99
|
+
* On error expanding any pattern, returns the error.
|
|
100
|
+
* Empty matches return the original pattern.
|
|
101
|
+
*/
|
|
102
|
+
export async function wildcards_expandAll(args) {
|
|
103
|
+
const expanded = [];
|
|
104
|
+
for (const arg of args) {
|
|
105
|
+
const result = await wildcard_expand(arg);
|
|
106
|
+
if (!result.ok) {
|
|
107
|
+
// Propagate error up
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
// If no matches, use original pattern (let command handle "not found")
|
|
111
|
+
if (result.value.length === 0) {
|
|
112
|
+
expanded.push(arg);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
expanded.push(...result.value);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return Ok(expanded);
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=wildcard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wildcard.js","sourceRoot":"","sources":["../../src/builtins/wildcard.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,E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AAC,OAAO,EAAE,8BAA8B,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC;QACtF,OAAO,GAAG,EAAE,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAc;IACtD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAqB,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC;QAE5D,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,qBAAqB;YACrB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,uEAAuE;QACvE,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC"}
|
package/dist/chell.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spawns the `chili` CLI as a child process.
|
|
3
|
+
*
|
|
4
|
+
* @param command - The command to run (e.g., "feeds").
|
|
5
|
+
* @param args - The arguments to pass to the command.
|
|
6
|
+
* @returns A Promise resolving when the child process exits.
|
|
7
|
+
*/
|
|
8
|
+
export declare function chiliCommand_run(command: string, args: string[]): Promise<void>;
|
|
9
|
+
export { COMMAND_HANDLERS_KEYS } from './command-keys.js';
|
|
10
|
+
/**
|
|
11
|
+
* Starts the ChELL REPL.
|
|
12
|
+
* Initializes connection and enters the command loop.
|
|
13
|
+
*
|
|
14
|
+
* @returns A Promise that resolves when the shell exits.
|
|
15
|
+
*/
|
|
16
|
+
export declare function chell_start(): Promise<void>;
|