@fnndsc/brasa 0.56.0 → 0.56.2
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/buildinfo.json +1 -1
- package/dist/builtins/berth/berth.d.ts +90 -3
- package/dist/builtins/berth/berth.js +129 -76
- package/dist/builtins/berth/berth.js.map +1 -1
- package/dist/builtins/berth/berthClose.d.ts +25 -6
- package/dist/builtins/berth/berthClose.js +19 -67
- package/dist/builtins/berth/berthClose.js.map +1 -1
- package/dist/builtins/berth/berthCube.js +4 -6
- package/dist/builtins/berth/berthCube.js.map +1 -1
- package/dist/builtins/berth/berthProcesses.d.ts +15 -0
- package/dist/builtins/berth/berthProcesses.js +58 -5
- package/dist/builtins/berth/berthProcesses.js.map +1 -1
- package/dist/builtins/fs/cat.js +3 -3
- package/dist/builtins/fs/cat.js.map +1 -1
- package/dist/builtins/fs/cp.js +3 -2
- package/dist/builtins/fs/cp.js.map +1 -1
- package/dist/builtins/fs/download.d.ts +31 -4
- package/dist/builtins/fs/download.js +75 -38
- package/dist/builtins/fs/download.js.map +1 -1
- package/dist/builtins/fs/ls.d.ts +69 -4
- package/dist/builtins/fs/ls.js +84 -45
- package/dist/builtins/fs/ls.js.map +1 -1
- package/dist/builtins/fs/pull.js +37 -9
- package/dist/builtins/fs/pull.js.map +1 -1
- package/dist/builtins/help.d.ts +3 -1
- package/dist/builtins/help.js +22 -33
- package/dist/builtins/help.js.map +1 -1
- package/dist/builtins/res/dicom.d.ts +3 -4
- package/dist/builtins/res/dicom.js +5 -19
- package/dist/builtins/res/dicom.js.map +1 -1
- package/dist/builtins/sys/textFilters.js +2 -2
- package/dist/builtins/sys/textFilters.js.map +1 -1
- package/dist/builtins/utils.d.ts +1 -1
- package/dist/builtins/utils.js +1 -1
- package/dist/builtins/utils.js.map +1 -1
- package/dist/chris/backend.js +2 -0
- package/dist/chris/backend.js.map +1 -1
- package/dist/chris/chrisCommands.js +6 -9
- package/dist/chris/chrisCommands.js.map +1 -1
- package/dist/chris/files.js +24 -85
- package/dist/chris/files.js.map +1 -1
- package/dist/chris/help.js +0 -64
- package/dist/chris/help.js.map +1 -1
- package/dist/chris/kinds.d.ts +9 -0
- package/dist/chris/kinds.js +42 -0
- package/dist/chris/kinds.js.map +1 -0
- package/dist/chris/promptContext.d.ts +6 -0
- package/dist/chris/promptContext.js +3 -1
- package/dist/chris/promptContext.js.map +1 -1
- package/dist/core/argumentKinds.d.ts +107 -0
- package/dist/core/argumentKinds.js +223 -0
- package/dist/core/argumentKinds.js.map +1 -0
- package/dist/core/backend.d.ts +4 -1
- package/dist/core/backend.js.map +1 -1
- package/dist/core/commandDeclaration.d.ts +363 -0
- package/dist/core/commandDeclaration.js +31 -0
- package/dist/core/commandDeclaration.js.map +1 -0
- package/dist/core/commandParse.d.ts +64 -0
- package/dist/core/commandParse.js +420 -0
- package/dist/core/commandParse.js.map +1 -0
- package/dist/core/commandRegistry.d.ts +36 -0
- package/dist/core/commandRegistry.js +72 -3
- package/dist/core/commandRegistry.js.map +1 -1
- package/dist/core/commandSchema.d.ts +32 -0
- package/dist/core/commandSchema.js +114 -0
- package/dist/core/commandSchema.js.map +1 -0
- package/dist/core/commandUsage.d.ts +47 -0
- package/dist/core/commandUsage.js +195 -0
- package/dist/core/commandUsage.js.map +1 -0
- package/dist/core/coreCommands.js +5 -4
- package/dist/core/coreCommands.js.map +1 -1
- package/dist/core/dispatch.js +15 -8
- package/dist/core/dispatch.js.map +1 -1
- package/dist/core/paths.d.ts +23 -0
- package/dist/core/paths.js +73 -2
- package/dist/core/paths.js.map +1 -1
- package/dist/core/preprocess.d.ts +10 -8
- package/dist/core/preprocess.js +11 -20
- package/dist/core/preprocess.js.map +1 -1
- package/dist/core/warmupFailures.d.ts +34 -2
- package/dist/core/warmupFailures.js +43 -2
- package/dist/core/warmupFailures.js.map +1 -1
- package/dist/lib/completer/cfsPaths.d.ts +14 -0
- package/dist/lib/completer/cfsPaths.js +91 -0
- package/dist/lib/completer/cfsPaths.js.map +1 -0
- package/dist/lib/completer/declared.d.ts +15 -0
- package/dist/lib/completer/declared.js +186 -0
- package/dist/lib/completer/declared.js.map +1 -0
- package/dist/lib/completer/index.js +33 -74
- package/dist/lib/completer/index.js.map +1 -1
- package/dist/lib/parser.d.ts +5 -0
- package/dist/lib/parser.js +2 -0
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/vfs/vfs.js +4 -2
- package/dist/lib/vfs/vfs.js.map +1 -1
- package/dist/lib/wildcard.js +2 -3
- package/dist/lib/wildcard.js.map +1 -1
- package/dist/notes.json +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ShellWord } from '../lib/parser.js';
|
|
3
|
+
import type { ArgumentGrammar } from './commandDeclaration.js';
|
|
4
|
+
/** What checking a word came to: its value, or why it is not one, in a few words (`valid: a, b`). */
|
|
5
|
+
export type ArgumentCheck = {
|
|
6
|
+
readonly ok: true;
|
|
7
|
+
readonly value: unknown;
|
|
8
|
+
} | {
|
|
9
|
+
readonly ok: false;
|
|
10
|
+
readonly reason: string;
|
|
11
|
+
};
|
|
12
|
+
/** What expanding a word came to: its words, or why it could not be expanded. */
|
|
13
|
+
export type ArgumentExpansion = {
|
|
14
|
+
readonly ok: true;
|
|
15
|
+
readonly words: ShellWord[];
|
|
16
|
+
} | {
|
|
17
|
+
readonly ok: false;
|
|
18
|
+
readonly reason: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* One kind of argument.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const colour: ArgumentKind = {
|
|
26
|
+
* name: 'colour',
|
|
27
|
+
* summary: 'A colour name',
|
|
28
|
+
* word_read: (word: string): ArgumentCheck => ({ ok: true, value: word }),
|
|
29
|
+
* schema_make: (): z.ZodType => z.string(),
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export interface ArgumentKind {
|
|
34
|
+
/** The name an argument gives as its `kind`. */
|
|
35
|
+
readonly name: string;
|
|
36
|
+
/** What it is, in a few words, for help and the schema. */
|
|
37
|
+
readonly summary: string;
|
|
38
|
+
/** A word that looks like a negative number is this kind's operand, not an option. */
|
|
39
|
+
readonly numeric?: boolean;
|
|
40
|
+
/** It is a path, so an argument of it may declare `glob`. */
|
|
41
|
+
readonly path?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Turns a word into its value, or says why it is not one.
|
|
44
|
+
*
|
|
45
|
+
* @param word - The word as the line gave it.
|
|
46
|
+
* @param argument - The argument's grammar (an enum's values, a number's bounds).
|
|
47
|
+
* @returns The value, or the reason.
|
|
48
|
+
*/
|
|
49
|
+
word_read(word: string, argument: ArgumentGrammar): ArgumentCheck;
|
|
50
|
+
/**
|
|
51
|
+
* The schema of the value, for a tool's input.
|
|
52
|
+
*
|
|
53
|
+
* @param argument - The argument's grammar.
|
|
54
|
+
* @returns The zod schema.
|
|
55
|
+
*/
|
|
56
|
+
schema_make(argument: ArgumentGrammar): z.ZodType;
|
|
57
|
+
/**
|
|
58
|
+
* Completes a word typed so far.
|
|
59
|
+
*
|
|
60
|
+
* @param partial - The word so far.
|
|
61
|
+
* @param argument - The argument's grammar.
|
|
62
|
+
* @returns The candidates that start with it.
|
|
63
|
+
*/
|
|
64
|
+
words_complete?(partial: string, argument: ArgumentGrammar): Promise<string[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Pathname expansion: the words a wildcard matches.
|
|
67
|
+
*
|
|
68
|
+
* @param words - The words, quoting kept.
|
|
69
|
+
* @returns The expanded words, a word matching nothing left as written.
|
|
70
|
+
*/
|
|
71
|
+
words_expand?(words: readonly ShellWord[]): Promise<ArgumentExpansion>;
|
|
72
|
+
}
|
|
73
|
+
/** The core's kind names, which a core command may use and no other. */
|
|
74
|
+
export declare const CORE_KIND_NAMES: ReadonlyArray<string>;
|
|
75
|
+
/**
|
|
76
|
+
* The candidates among some words that start with what was typed.
|
|
77
|
+
*
|
|
78
|
+
* @param words - The words.
|
|
79
|
+
* @param partial - What was typed.
|
|
80
|
+
* @returns Those that start with it.
|
|
81
|
+
*/
|
|
82
|
+
export declare function candidates_filter(words: ReadonlyArray<string>, partial: string): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Finds a kind: the core's, then the installed backend's.
|
|
85
|
+
*
|
|
86
|
+
* @param name - The kind's name.
|
|
87
|
+
* @returns The kind, or null when neither has it.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* argumentKind_get('cfsPath')?.path; // true
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function argumentKind_get(name: string): ArgumentKind | null;
|
|
95
|
+
/**
|
|
96
|
+
* Checks one word against its argument's kind.
|
|
97
|
+
*
|
|
98
|
+
* @param argument - The argument's grammar.
|
|
99
|
+
* @param word - The word.
|
|
100
|
+
* @returns The value, or why the word is not one (an unregistered kind says so).
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* argumentWord_check({ kind: 'enum', values: ['a', 'b'] }, 'c'); // { ok: false, reason: 'valid: a, b' }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function argumentWord_check(argument: ArgumentGrammar, word: string): ArgumentCheck;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { dirname, join, resolve } from 'node:path';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { backendInstalled_get } from './backend.js';
|
|
4
|
+
/** The core's kind names, which a core command may use and no other. */
|
|
5
|
+
export const CORE_KIND_NAMES = ['word', 'enum', 'int', 'number', 'cfsPath', 'hostPath', 'variable', 'job'];
|
|
6
|
+
/** A variable's name, as `set` and `${name}` spell it. */
|
|
7
|
+
const VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
8
|
+
/** A joblet as a word names it: `%3`, `3`, `%%`, `%+`, `%`. */
|
|
9
|
+
const JOB_WORD = /^(?:%?\d+|%%|%\+|%)$/;
|
|
10
|
+
/** A whole number as a word writes it. */
|
|
11
|
+
const INT_WORD = /^[+-]?\d+$/;
|
|
12
|
+
/**
|
|
13
|
+
* Checks a number against an argument's bounds.
|
|
14
|
+
*
|
|
15
|
+
* @param value - The number.
|
|
16
|
+
* @param argument - The argument, with its bounds.
|
|
17
|
+
* @returns The value, or why it is out of bounds.
|
|
18
|
+
*/
|
|
19
|
+
function bounds_check(value, argument) {
|
|
20
|
+
if (argument.min !== undefined && value < argument.min)
|
|
21
|
+
return { ok: false, reason: `at least ${argument.min}` };
|
|
22
|
+
if (argument.max !== undefined && value > argument.max)
|
|
23
|
+
return { ok: false, reason: `at most ${argument.max}` };
|
|
24
|
+
return { ok: true, value };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A number schema with an argument's bounds.
|
|
28
|
+
*
|
|
29
|
+
* @param base - The number schema.
|
|
30
|
+
* @param argument - The argument, with its bounds.
|
|
31
|
+
* @returns The schema, bounded.
|
|
32
|
+
*/
|
|
33
|
+
function numberSchema_bound(base, argument) {
|
|
34
|
+
let schema = base;
|
|
35
|
+
if (argument.min !== undefined)
|
|
36
|
+
schema = schema.min(argument.min);
|
|
37
|
+
if (argument.max !== undefined)
|
|
38
|
+
schema = schema.max(argument.max);
|
|
39
|
+
return schema;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Reads a word as text that is not empty.
|
|
43
|
+
*
|
|
44
|
+
* @param word - The word.
|
|
45
|
+
* @param what - What it should be, for the reason.
|
|
46
|
+
* @returns The word, or why it is not one.
|
|
47
|
+
*/
|
|
48
|
+
function text_read(word, what) {
|
|
49
|
+
return word === '' ? { ok: false, reason: `an empty word is not ${what}` } : { ok: true, value: word };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The candidates among some words that start with what was typed.
|
|
53
|
+
*
|
|
54
|
+
* @param words - The words.
|
|
55
|
+
* @param partial - What was typed.
|
|
56
|
+
* @returns Those that start with it.
|
|
57
|
+
*/
|
|
58
|
+
export function candidates_filter(words, partial) {
|
|
59
|
+
return words.filter((word) => word.startsWith(partial));
|
|
60
|
+
}
|
|
61
|
+
/** Any word at all. */
|
|
62
|
+
const WORD_KIND = {
|
|
63
|
+
name: 'word',
|
|
64
|
+
summary: 'a word',
|
|
65
|
+
word_read: (word) => ({ ok: true, value: word }),
|
|
66
|
+
schema_make: () => z.string(),
|
|
67
|
+
};
|
|
68
|
+
/** One of the words an argument lists. */
|
|
69
|
+
const ENUM_KIND = {
|
|
70
|
+
name: 'enum',
|
|
71
|
+
summary: 'one of the listed words',
|
|
72
|
+
word_read: (word, argument) => {
|
|
73
|
+
const values = argument.values ?? [];
|
|
74
|
+
return values.includes(word) ? { ok: true, value: word } : { ok: false, reason: `valid: ${values.join(', ')}` };
|
|
75
|
+
},
|
|
76
|
+
schema_make: (argument) => z.enum([...(argument.values ?? [])]),
|
|
77
|
+
words_complete: async (partial, argument) => candidates_filter(argument.values ?? [], partial),
|
|
78
|
+
};
|
|
79
|
+
/** A whole number. */
|
|
80
|
+
const INT_KIND = {
|
|
81
|
+
name: 'int',
|
|
82
|
+
summary: 'a whole number',
|
|
83
|
+
numeric: true,
|
|
84
|
+
word_read: (word, argument) => INT_WORD.test(word) ? bounds_check(Number(word), argument) : { ok: false, reason: 'not a whole number' },
|
|
85
|
+
schema_make: (argument) => numberSchema_bound(z.number().int(), argument),
|
|
86
|
+
};
|
|
87
|
+
/** A number, whole or not. */
|
|
88
|
+
const NUMBER_KIND = {
|
|
89
|
+
name: 'number',
|
|
90
|
+
summary: 'a number',
|
|
91
|
+
numeric: true,
|
|
92
|
+
word_read: (word, argument) => {
|
|
93
|
+
const value = word.trim() === '' ? Number.NaN : Number(word);
|
|
94
|
+
return Number.isFinite(value) ? bounds_check(value, argument) : { ok: false, reason: 'not a number' };
|
|
95
|
+
},
|
|
96
|
+
schema_make: (argument) => numberSchema_bound(z.number(), argument),
|
|
97
|
+
};
|
|
98
|
+
/** A path in ChRIS's filesystem (CFS), as the session resolves it. */
|
|
99
|
+
const CFS_PATH_KIND = {
|
|
100
|
+
name: 'cfsPath',
|
|
101
|
+
summary: "a path in ChRIS's filesystem",
|
|
102
|
+
path: true,
|
|
103
|
+
word_read: (word) => text_read(word, 'a path'),
|
|
104
|
+
schema_make: () => z.string().min(1),
|
|
105
|
+
words_complete: async (partial) => {
|
|
106
|
+
const { cfsPaths_complete } = await import('../lib/completer/cfsPaths.js');
|
|
107
|
+
return cfsPaths_complete(partial);
|
|
108
|
+
},
|
|
109
|
+
words_expand: async (words) => {
|
|
110
|
+
const { shellWords_expand } = await import('../lib/wildcard.js');
|
|
111
|
+
const { errorStack } = await import('@fnndsc/fond');
|
|
112
|
+
const expanded = await shellWords_expand(words, () => true);
|
|
113
|
+
if (expanded.ok)
|
|
114
|
+
return { ok: true, words: expanded.value };
|
|
115
|
+
const reason = errorStack.stack_pop()?.message;
|
|
116
|
+
return { ok: false, reason: reason ?? 'a wildcard could not be expanded' };
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* The folders and files under a host folder that start with a name, for
|
|
121
|
+
* completion of a host path.
|
|
122
|
+
*
|
|
123
|
+
* The disk is loaded when asked, so parsing a line loads no filesystem.
|
|
124
|
+
*
|
|
125
|
+
* @param partial - The path typed so far.
|
|
126
|
+
* @returns The candidates, a folder ending in `/`; none when the folder cannot be read.
|
|
127
|
+
*/
|
|
128
|
+
async function hostPaths_list(partial) {
|
|
129
|
+
const { readdirSync } = await import('node:fs');
|
|
130
|
+
const { homedir } = await import('node:os');
|
|
131
|
+
const expanded = partial.startsWith('~/') ? join(homedir(), partial.slice(2)) : partial;
|
|
132
|
+
const folder = expanded.endsWith('/') ? expanded : dirname(expanded);
|
|
133
|
+
const typedFolder = partial.endsWith('/') ? partial : partial.slice(0, partial.lastIndexOf('/') + 1);
|
|
134
|
+
const prefix = expanded.endsWith('/') ? '' : expanded.slice(expanded.lastIndexOf('/') + 1);
|
|
135
|
+
let entries = [];
|
|
136
|
+
try {
|
|
137
|
+
entries = readdirSync(resolve(folder === '' ? '.' : folder), { withFileTypes: true });
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
return entries
|
|
143
|
+
.filter((entry) => entry.name.startsWith(prefix))
|
|
144
|
+
.map((entry) => `${typedFolder}${entry.name}${entry.isDirectory() ? '/' : ''}`)
|
|
145
|
+
.sort();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A path on the host the operator's surface sits on. It completes from the
|
|
149
|
+
* engine's own disk only when that disk is the surface's: under a daemon the
|
|
150
|
+
* engine's disk is a machine nobody at the surface sits at.
|
|
151
|
+
*/
|
|
152
|
+
const HOST_PATH_KIND = {
|
|
153
|
+
name: 'hostPath',
|
|
154
|
+
summary: "a path on this machine's filesystem",
|
|
155
|
+
path: true,
|
|
156
|
+
word_read: (word) => text_read(word, 'a path'),
|
|
157
|
+
schema_make: () => z.string().min(1),
|
|
158
|
+
words_complete: async (partial) => {
|
|
159
|
+
const { surface_get } = await import('./surface.js');
|
|
160
|
+
return surface_get().capabilities.engineFilesystem ? hostPaths_list(partial) : [];
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
/** A session variable's name. */
|
|
164
|
+
const VARIABLE_KIND = {
|
|
165
|
+
name: 'variable',
|
|
166
|
+
summary: 'a variable name',
|
|
167
|
+
word_read: (word) => VARIABLE_NAME.test(word) ? { ok: true, value: word } : { ok: false, reason: 'not a variable name' },
|
|
168
|
+
schema_make: () => z.string().regex(VARIABLE_NAME),
|
|
169
|
+
words_complete: async (partial) => {
|
|
170
|
+
const { variables_list } = await import('./variables.js');
|
|
171
|
+
return candidates_filter(variables_list().map((variable) => variable.name), partial);
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
/** A joblet: `%3`, `3`, or the most recent, `%%`. */
|
|
175
|
+
const JOB_KIND = {
|
|
176
|
+
name: 'job',
|
|
177
|
+
summary: 'a job: %N, or %% for the most recent',
|
|
178
|
+
word_read: (word) => JOB_WORD.test(word) ? { ok: true, value: word } : { ok: false, reason: 'a job is %N, or %% for the most recent' },
|
|
179
|
+
schema_make: () => z.string().regex(JOB_WORD),
|
|
180
|
+
words_complete: async (partial) => {
|
|
181
|
+
const { joblets_running } = await import('./joblets.js');
|
|
182
|
+
return candidates_filter(joblets_running().map((joblet) => `%${joblet.number}`), partial);
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
/** The core's kinds, by name. */
|
|
186
|
+
const CORE_KINDS = new Map([WORD_KIND, ENUM_KIND, INT_KIND, NUMBER_KIND, CFS_PATH_KIND, HOST_PATH_KIND, VARIABLE_KIND, JOB_KIND]
|
|
187
|
+
.map((kind) => [kind.name, kind]));
|
|
188
|
+
/**
|
|
189
|
+
* Finds a kind: the core's, then the installed backend's.
|
|
190
|
+
*
|
|
191
|
+
* @param name - The kind's name.
|
|
192
|
+
* @returns The kind, or null when neither has it.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* argumentKind_get('cfsPath')?.path; // true
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
export function argumentKind_get(name) {
|
|
200
|
+
const core = CORE_KINDS.get(name);
|
|
201
|
+
if (core !== undefined)
|
|
202
|
+
return core;
|
|
203
|
+
return backendInstalled_get()?.argumentKinds?.find((kind) => kind.name === name) ?? null;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Checks one word against its argument's kind.
|
|
207
|
+
*
|
|
208
|
+
* @param argument - The argument's grammar.
|
|
209
|
+
* @param word - The word.
|
|
210
|
+
* @returns The value, or why the word is not one (an unregistered kind says so).
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* argumentWord_check({ kind: 'enum', values: ['a', 'b'] }, 'c'); // { ok: false, reason: 'valid: a, b' }
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export function argumentWord_check(argument, word) {
|
|
218
|
+
const kind = argumentKind_get(argument.kind);
|
|
219
|
+
if (kind === null)
|
|
220
|
+
return { ok: false, reason: `this session has no argument kind ${argument.kind}` };
|
|
221
|
+
return kind.word_read(word, argument);
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=argumentKinds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argumentKinds.js","sourceRoot":"","sources":["../../src/core/argumentKinds.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAkEpD,wEAAwE;AACxE,MAAM,CAAC,MAAM,eAAe,GAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AAElI,0DAA0D;AAC1D,MAAM,aAAa,GAAW,0BAA0B,CAAC;AAEzD,+DAA+D;AAC/D,MAAM,QAAQ,GAAW,sBAAsB,CAAC;AAEhD,0CAA0C;AAC1C,MAAM,QAAQ,GAAW,YAAY,CAAC;AAEtC;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,KAAa,EAAE,QAAyB;IAC5D,IAAI,QAAQ,CAAC,GAAG,KAAK,SAAS,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC;IACjH,IAAI,QAAQ,CAAC,GAAG,KAAK,SAAS,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,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AC;AACxC,CAAC"}
|
package/dist/core/backend.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { PromptContext, CubeTelemetry, JobsStateTelemetry, CommandEnvelope,
|
|
|
17
17
|
import type { ReferenceValue } from '../lib/parser.js';
|
|
18
18
|
import type { ListingLook, VFSDispatcher } from '@fnndsc/fond';
|
|
19
19
|
import type { ListingItem } from '@fnndsc/menu';
|
|
20
|
+
import type { ArgumentKind } from './argumentKinds.js';
|
|
20
21
|
/**
|
|
21
22
|
* Who a session is and where: the input a host keys the session by (calypso's
|
|
22
23
|
* berth name is `user@where`, normalised).
|
|
@@ -212,7 +213,7 @@ export interface BackendFilesystem {
|
|
|
212
213
|
* cleared): a listing that fails says the path was walked as written.
|
|
213
214
|
*/
|
|
214
215
|
readonly unreadLinks_take?: () => Promise<string[]>;
|
|
215
|
-
/** A
|
|
216
|
+
/** A store path with the store's own links followed, at any depth (ChRIS: `.chrislink`s); absent, the path as given. `storePath_resolve` asks it for every read and listing, and globbing for a folder. */
|
|
216
217
|
readonly path_physical?: (path: string) => Promise<string>;
|
|
217
218
|
/** Paths that are always folders, entered without asking (beside the mounts and the folders above them). */
|
|
218
219
|
readonly structural?: ReadonlyArray<string>;
|
|
@@ -321,6 +322,8 @@ export interface Backend {
|
|
|
321
322
|
readonly vfs?: BackendFilesystem;
|
|
322
323
|
/** What it adds to completion. */
|
|
323
324
|
readonly completion?: BackendCompletion;
|
|
325
|
+
/** The argument kinds its commands declare beside the core's (ChRIS: an anchor's name); a kind is found among the core's first. */
|
|
326
|
+
readonly argumentKinds?: ReadonlyArray<ArgumentKind>;
|
|
324
327
|
/** How its listings show: the kinds it lists beside the core's, and how a name is coloured. */
|
|
325
328
|
readonly listingLook?: ListingLook;
|
|
326
329
|
/** Whether the backend is debugging (error messages keep their function stamp), or null before it can say. */
|
package/dist/core/backend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../../src/core/backend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../../src/core/backend.ts"],"names":[],"mappings":"AA+VA,IAAI,SAAS,GAAmB,IAAI,CAAC;AAErC;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,SAAS,GAAG,OAAO,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW;IACzB,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,uFAAuF,CAAC,CAAC;IAC3G,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|