@fnndsc/brasa 0.36.0 → 0.37.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/dist/buildinfo.json +1 -1
- package/dist/builtins/help.d.ts +7 -0
- package/dist/builtins/help.js +74 -73
- package/dist/builtins/help.js.map +1 -1
- package/dist/builtins/helpSections.d.ts +88 -0
- package/dist/builtins/helpSections.js +237 -0
- package/dist/builtins/helpSections.js.map +1 -0
- package/dist/builtins/sys/apropos.d.ts +22 -0
- package/dist/builtins/sys/apropos.js +41 -0
- package/dist/builtins/sys/apropos.js.map +1 -0
- package/dist/chris/help.js +44 -44
- package/dist/chris/help.js.map +1 -1
- package/dist/core/coreCommands.js +5 -0
- package/dist/core/coreCommands.js.map +1 -1
- package/dist/notes.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file help's sections: the table of contents `help` shows, a section's
|
|
3
|
+
* page (`help PACS`), the Shell topics (`help pipes`), and `apropos`.
|
|
4
|
+
*
|
|
5
|
+
* Borrowed from man rather than reinvented: sections by topic (man's are by
|
|
6
|
+
* number), a page per command, and `apropos` / `man -k` to search every
|
|
7
|
+
* summary by a word, which is how anyone finds a command they cannot name.
|
|
8
|
+
* A section is one capitalised word, so `help PACS` (the section) and
|
|
9
|
+
* `help pacs` (the command) never collide; a section word that names no
|
|
10
|
+
* command answers in lower case too.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import chalk from 'chalk';
|
|
15
|
+
/** The sections, in the order `help` lists them. */
|
|
16
|
+
export const HELP_SECTIONS = [
|
|
17
|
+
{ name: 'Navigation', blurb: "Move around ChRIS's filesystem, including the /proc and /net projections.", examples: ['cd', 'ls', 'tree', 'du', 'cubepath'] },
|
|
18
|
+
{ name: 'Files', blurb: 'Read, write, copy and move files and folders; upload from and download to this machine.', examples: ['cat', 'cp', 'mv', 'upload', 'download', 'grep'] },
|
|
19
|
+
{ name: 'Sharing', blurb: 'Who may see a folder or file, and links that open ARGUS where you are.', examples: ['chmod', 'setfacl', 'url'] },
|
|
20
|
+
{ name: 'Connection', blurb: 'Who you are, which CUBE you are on, and where the session stands.', examples: ['connect', 'whoami', 'context'] },
|
|
21
|
+
{ name: 'Monitoring', blurb: 'Live jobs as a filesystem, and jumping to one by number.', examples: ['proc'] },
|
|
22
|
+
{ name: 'Imaging', blurb: 'DICOM tags and image viewing.', examples: ['dcm', 'image'] },
|
|
23
|
+
{ name: 'Workflows', blurb: 'Gather a cohort, record what you do as a manifest, and replay it.', examples: ['gather', 'record', 'play', 'expect'] },
|
|
24
|
+
{ name: 'Resources', blurb: 'ChRIS resources one at a time or as lists: feeds, plugins, pipelines, jobs, tags, groups, compute, store.', examples: ['feed', 'feeds', 'plugins', 'jobs'] },
|
|
25
|
+
{ name: 'PACS', blurb: "Ask a PACS for a patient's studies and series, narrow the answer, and pull it into ChRIS.", examples: ['query', 'pull', 'pacs'] },
|
|
26
|
+
{ name: 'Admin', blurb: 'Administrative acts that need elevated rights.', examples: ['sudo', 'user'] },
|
|
27
|
+
{ name: 'Settings', blurb: 'How the shell behaves: prompt, timing, physical paths, debug output.', examples: ['prompt', 'timing', 'debug'] },
|
|
28
|
+
{ name: 'Games', blurb: 'The /usr/games shelf: text toys, small utilities and games.', examples: ['fortune', 'cowsay', 'tetris'] },
|
|
29
|
+
{ name: 'General', blurb: 'Help, finding a command by a word, release notes, versions, and leaving.', examples: ['help', 'apropos', 'notes', 'version', 'exit'] },
|
|
30
|
+
];
|
|
31
|
+
/** The section that is not a list of commands: what the shell does to a line. */
|
|
32
|
+
export const SHELL_SECTION = {
|
|
33
|
+
name: 'Shell',
|
|
34
|
+
blurb: 'What the shell does to a line: pipes, redirection, index handles (@SER3), pronouns (${cwd}), listing-aware grep, command.',
|
|
35
|
+
examples: ['help pipes', 'help handles', 'help pronouns'],
|
|
36
|
+
};
|
|
37
|
+
/** The Shell section's topics, each `help <topic>`. */
|
|
38
|
+
export const SHELL_TOPICS = [
|
|
39
|
+
{
|
|
40
|
+
name: 'pipes',
|
|
41
|
+
summary: 'cmd | cmd: text between programs, a numbered listing between builtins',
|
|
42
|
+
page: [
|
|
43
|
+
'A pipe hands one command\'s output to the next: cat notes.txt | wc -l.',
|
|
44
|
+
'',
|
|
45
|
+
'Between two builtins a numbered listing travels beside the text, so the',
|
|
46
|
+
'next builtin receives rows, not words:',
|
|
47
|
+
' query PatientID:1234567 | grep -i t1 | gather add',
|
|
48
|
+
'A program that is not a builtin (sort, awk, a system grep) receives the',
|
|
49
|
+
'text alone. The last listing a pipe produces becomes the held listing:',
|
|
50
|
+
'@SER3 and ${listing} name its rows afterwards.',
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'redirection',
|
|
55
|
+
summary: '> and >>: write or append a command\'s output to a file on this machine',
|
|
56
|
+
page: [
|
|
57
|
+
'cmd > file writes the output to a file; cmd >> file appends to it.',
|
|
58
|
+
'',
|
|
59
|
+
'The file is on the machine chell runs on, not in ChRIS: to put text in',
|
|
60
|
+
'ChRIS use touch --withContents or upload.',
|
|
61
|
+
' query PatientID:1234567 --table > answer.txt',
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'handles',
|
|
66
|
+
summary: '@SER3 @STD1-4 @FIL2,5,7: name rows of the last numbered listing',
|
|
67
|
+
page: [
|
|
68
|
+
'A listing that numbers its rows (query, query --table, gather list,',
|
|
69
|
+
'ls -l) prints a handle beside each: @PAT1, @STD3, @SER12, @DIR4, @FIL2.',
|
|
70
|
+
'Typed in a later line, a handle stands for its row:',
|
|
71
|
+
' gather add @SER3 one row',
|
|
72
|
+
' gather add @SER1-4 a range',
|
|
73
|
+
' gather add @SER2,5,7 a list',
|
|
74
|
+
'',
|
|
75
|
+
'The listing\'s footer says what is numbered now:',
|
|
76
|
+
' numbered: @PAT1, @STD1-9, @SER1-235',
|
|
77
|
+
'The next listing replaces it, so @SER3 always means the last listing\'s',
|
|
78
|
+
'row. grep keeps the handles rows already wore (@SER41 stays @SER41).',
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{ name: 'pronouns', summary: '${cwd} ${listing} …: what this session just made or asked' },
|
|
82
|
+
{ name: 'grep', summary: 'filter text, or a numbered listing keeping its handles' },
|
|
83
|
+
{ name: 'command', summary: 'run the system program, not the builtin' },
|
|
84
|
+
];
|
|
85
|
+
/** Wraps a paragraph to a width, each line indented. */
|
|
86
|
+
function paragraph_wrap(text, indent, width = 78) {
|
|
87
|
+
const lines = [];
|
|
88
|
+
let line = '';
|
|
89
|
+
for (const word of text.split(/\s+/)) {
|
|
90
|
+
if (line !== '' && indent.length + line.length + 1 + word.length > width) {
|
|
91
|
+
lines.push(`${indent}${line}`);
|
|
92
|
+
line = word;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
line = line === '' ? word : `${line} ${word}`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (line !== '')
|
|
99
|
+
lines.push(`${indent}${line}`);
|
|
100
|
+
return lines;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A section's commands: those that declare it, and for Games the shelf.
|
|
104
|
+
*
|
|
105
|
+
* @param section - The section's name.
|
|
106
|
+
* @param lookup - The commands.
|
|
107
|
+
* @returns Its runnable commands.
|
|
108
|
+
*/
|
|
109
|
+
export function sectionCommands_of(section, lookup) {
|
|
110
|
+
const declared = lookup.commands().filter((name) => lookup.section(name) === section);
|
|
111
|
+
if (section !== 'Games')
|
|
112
|
+
return declared;
|
|
113
|
+
return [...new Set([...declared, ...lookup.games()])];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* `help`: the table of contents. A section with nothing this session can
|
|
117
|
+
* run is left out, as are examples it cannot run.
|
|
118
|
+
*
|
|
119
|
+
* @param lookup - The commands.
|
|
120
|
+
* @returns The page.
|
|
121
|
+
*/
|
|
122
|
+
export function helpToc_render(lookup) {
|
|
123
|
+
const runnable = new Set(lookup.commands());
|
|
124
|
+
const out = [
|
|
125
|
+
'',
|
|
126
|
+
chalk.bold.yellow('chell — the ChRIS shell'),
|
|
127
|
+
chalk.gray('Type help <Section> for a section, help <command> for a command, apropos <word> to search.'),
|
|
128
|
+
'',
|
|
129
|
+
];
|
|
130
|
+
const entry = (section, count) => {
|
|
131
|
+
out.push(`${chalk.bold.cyan(section.name)}${count === null ? '' : chalk.gray(` (${count})`)}`);
|
|
132
|
+
out.push(...paragraph_wrap(section.blurb, ' '));
|
|
133
|
+
const shown = section === SHELL_SECTION ? [...section.examples] : section.examples.filter((name) => runnable.has(name) || lookup.games().includes(name));
|
|
134
|
+
if (shown.length > 0)
|
|
135
|
+
out.push(` ${chalk.gray('e.g.')} ${shown.map((name) => chalk.yellow(name)).join(' ')}`);
|
|
136
|
+
out.push('');
|
|
137
|
+
};
|
|
138
|
+
for (const section of HELP_SECTIONS) {
|
|
139
|
+
const count = sectionCommands_of(section.name, lookup).length;
|
|
140
|
+
if (count > 0)
|
|
141
|
+
entry(section, count);
|
|
142
|
+
}
|
|
143
|
+
entry(SHELL_SECTION, null);
|
|
144
|
+
if (runnable.has('query') && runnable.has('gather')) {
|
|
145
|
+
out.push(`${chalk.gray('Start here:')} ${chalk.yellow('query PatientID:1234567 | grep -i t1 | gather add')}`, '');
|
|
146
|
+
}
|
|
147
|
+
return `${out.join('\n')}\n`;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The section a word names: exactly (`PACS`), or in any case when no command
|
|
151
|
+
* has that name (`navigation`).
|
|
152
|
+
*
|
|
153
|
+
* @param word - What followed `help`.
|
|
154
|
+
* @param isCommand - Whether a command has that name.
|
|
155
|
+
* @returns The section, or undefined.
|
|
156
|
+
*/
|
|
157
|
+
export function section_find(word, isCommand) {
|
|
158
|
+
const all = [...HELP_SECTIONS, SHELL_SECTION];
|
|
159
|
+
const exact = all.find((section) => section.name === word);
|
|
160
|
+
if (exact !== undefined)
|
|
161
|
+
return exact;
|
|
162
|
+
if (isCommand(word))
|
|
163
|
+
return undefined;
|
|
164
|
+
return all.find((section) => section.name.toLowerCase() === word.toLowerCase());
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A section's page: what it is for, then each command with its line.
|
|
168
|
+
*
|
|
169
|
+
* @param section - The section.
|
|
170
|
+
* @param lookup - The commands.
|
|
171
|
+
* @returns The page.
|
|
172
|
+
*/
|
|
173
|
+
export function helpSection_render(section, lookup) {
|
|
174
|
+
const out = ['', `${chalk.bold.cyan(section.name)} ${chalk.gray('—')} ${section.blurb}`, ''];
|
|
175
|
+
const rows = section === SHELL_SECTION
|
|
176
|
+
? SHELL_TOPICS.map((topic) => ({ name: topic.name, line: topic.summary }))
|
|
177
|
+
: sectionCommands_of(section.name, lookup).map((name) => ({ name, line: lookup.summary(name) ?? '' }));
|
|
178
|
+
const width = Math.max(12, ...rows.map((row) => row.name.length + 2));
|
|
179
|
+
for (const row of rows)
|
|
180
|
+
out.push(` ${chalk.cyan(row.name.padEnd(width))}${row.line}`);
|
|
181
|
+
out.push('', chalk.gray(`help <${section === SHELL_SECTION ? 'topic' : 'command'}> for each.`), '');
|
|
182
|
+
return `${out.join('\n')}\n`;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A Shell topic's own page, or undefined when it is not one (or is a
|
|
186
|
+
* command, whose own page answers).
|
|
187
|
+
*
|
|
188
|
+
* @param word - What followed `help`.
|
|
189
|
+
* @returns The page.
|
|
190
|
+
*/
|
|
191
|
+
export function shellTopic_render(word) {
|
|
192
|
+
const topic = SHELL_TOPICS.find((one) => one.name === word && one.page !== undefined);
|
|
193
|
+
if (topic === undefined || topic.page === undefined)
|
|
194
|
+
return undefined;
|
|
195
|
+
return `\n${chalk.bold.yellow(topic.name.toUpperCase())}\n${chalk.gray('─'.repeat(60))}\n${topic.page.join('\n')}\n\n${chalk.gray('help Shell for the other topics.')}\n`;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* `apropos <word>` (`man -k`): what holds the word, strongest first. A
|
|
199
|
+
* section, a command or a Shell topic whose name or one line holds it leads;
|
|
200
|
+
* one that only mentions it further in (its description, its options)
|
|
201
|
+
* follows, under "also mentioned in", so `apropos dicom` leads with dcm and
|
|
202
|
+
* image rather than a game that happens to name DICOM.
|
|
203
|
+
*
|
|
204
|
+
* @param word - What to look for.
|
|
205
|
+
* @param lookup - The commands.
|
|
206
|
+
* @returns The lines, empty when nothing holds the word.
|
|
207
|
+
*/
|
|
208
|
+
export function apropos_search(word, lookup) {
|
|
209
|
+
const needle = word.toLowerCase();
|
|
210
|
+
const holds = (text) => text.toLowerCase().includes(needle);
|
|
211
|
+
const strong = [];
|
|
212
|
+
const mentioned = [];
|
|
213
|
+
for (const section of [...HELP_SECTIONS, SHELL_SECTION]) {
|
|
214
|
+
if (holds(`${section.name} ${section.blurb}`))
|
|
215
|
+
strong.push(`${chalk.cyan(section.name)} ${chalk.gray('(section)')} — ${section.blurb}`);
|
|
216
|
+
}
|
|
217
|
+
for (const name of lookup.commands()) {
|
|
218
|
+
const line = `${chalk.cyan(name)} ${chalk.gray(`(${lookup.section(name) ?? 'General'})`)} — ${lookup.summary(name) ?? ''}`;
|
|
219
|
+
if (holds(`${name} ${lookup.summary(name) ?? ''}`))
|
|
220
|
+
strong.push(line);
|
|
221
|
+
else if (holds(lookup.text(name)))
|
|
222
|
+
mentioned.push(line);
|
|
223
|
+
}
|
|
224
|
+
for (const topic of SHELL_TOPICS) {
|
|
225
|
+
if (lookup.commands().includes(topic.name))
|
|
226
|
+
continue;
|
|
227
|
+
const line = `${chalk.cyan(topic.name)} ${chalk.gray('(Shell)')} — ${topic.summary}`;
|
|
228
|
+
if (holds(`${topic.name} ${topic.summary}`))
|
|
229
|
+
strong.push(line);
|
|
230
|
+
else if (holds((topic.page ?? []).join(' ')))
|
|
231
|
+
mentioned.push(line);
|
|
232
|
+
}
|
|
233
|
+
if (mentioned.length === 0)
|
|
234
|
+
return strong;
|
|
235
|
+
return [...strong, ...(strong.length > 0 ? [''] : []), chalk.gray('also mentioned in:'), ...mentioned];
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=helpSections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpSections.js","sourceRoot":"","sources":["../../src/builtins/helpSections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,oDAAoD;AACpD,MAAM,CAAC,MAAM,aAAa,GAA+B;IACvD,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,2EAA2E,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE;IAC5J,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,yFAAyF,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE;IAChL,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,wEAAwE,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE;IAC3I,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,mEAAmE,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE;IAC9I,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,0DAA0D,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE;IAC7G,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,+BAA+B,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE;IACvF,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,mEAAmE,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,QA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AAI,CAAC,CAAC;IAC1D,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;QACjC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,SAAS;QACrD,MAAM,IAAI,GAAW,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAC7F,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC1D,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IAC1C,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;AACzG,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file apropos and man: find a command by a word, and read its page, in the
|
|
3
|
+
* words every Unix hand already knows (builtins/helpSections.ts).
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { CommandEnvelope } from '@fnndsc/menu';
|
|
8
|
+
/**
|
|
9
|
+
* `apropos <word>`: every command, section and Shell topic whose name,
|
|
10
|
+
* summary or description holds the word.
|
|
11
|
+
*
|
|
12
|
+
* @param args - The word (several words are one phrase).
|
|
13
|
+
* @returns The matches, or nothing appropriate (exit 1, as apropos does).
|
|
14
|
+
*/
|
|
15
|
+
export declare function builtin_apropos(args: string[]): Promise<CommandEnvelope>;
|
|
16
|
+
/**
|
|
17
|
+
* `man <command|Section|topic>` is `help` for it; `man -k <word>` is apropos.
|
|
18
|
+
*
|
|
19
|
+
* @param args - The words after `man`.
|
|
20
|
+
* @returns The page, or the matches.
|
|
21
|
+
*/
|
|
22
|
+
export declare function builtin_man(args: string[]): Promise<CommandEnvelope>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file apropos and man: find a command by a word, and read its page, in the
|
|
3
|
+
* words every Unix hand already knows (builtins/helpSections.ts).
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
8
|
+
import { apropos_search } from '../helpSections.js';
|
|
9
|
+
import { builtin_help, helpLookup_make } from '../help.js';
|
|
10
|
+
/**
|
|
11
|
+
* `apropos <word>`: every command, section and Shell topic whose name,
|
|
12
|
+
* summary or description holds the word.
|
|
13
|
+
*
|
|
14
|
+
* @param args - The word (several words are one phrase).
|
|
15
|
+
* @returns The matches, or nothing appropriate (exit 1, as apropos does).
|
|
16
|
+
*/
|
|
17
|
+
export async function builtin_apropos(args) {
|
|
18
|
+
const word = args.join(' ').trim();
|
|
19
|
+
if (word === '')
|
|
20
|
+
return envelope_error('', undefined, 'apropos: a word to look for: apropos <word>\n');
|
|
21
|
+
const hits = apropos_search(word, helpLookup_make());
|
|
22
|
+
if (hits.length === 0) {
|
|
23
|
+
process.exitCode = 1;
|
|
24
|
+
return envelope_ok(`${word}: nothing appropriate.\n`);
|
|
25
|
+
}
|
|
26
|
+
return envelope_ok(`${hits.join('\n')}\n`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* `man <command|Section|topic>` is `help` for it; `man -k <word>` is apropos.
|
|
30
|
+
*
|
|
31
|
+
* @param args - The words after `man`.
|
|
32
|
+
* @returns The page, or the matches.
|
|
33
|
+
*/
|
|
34
|
+
export async function builtin_man(args) {
|
|
35
|
+
if (args[0] === '-k')
|
|
36
|
+
return builtin_apropos(args.slice(1));
|
|
37
|
+
if (args.length === 0)
|
|
38
|
+
return envelope_error('', undefined, 'man: what manual page do you want? man <command>, man <Section>, man -k <word>\n');
|
|
39
|
+
return builtin_help(args);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=apropos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apropos.js","sourceRoot":"","sources":["../../../src/builtins/sys/apropos.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAc;IAClD,MAAM,IAAI,GAAW,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,+CAA+C,CAAC,CAAC;IACvG,MAAM,IAAI,GAAa,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;IAC/D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,WAAW,CAAC,GAAG,IAAI,0BAA0B,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,WAAW,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED;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