MCPcopy
hub / github.com/jasongin/nvs / help

Function help

lib/help.js:16–77  ·  view source on GitHub ↗

* Show help for a topic, or a summary of all help topics. * * @param {string} [topic]

(topic)

Source from the content-addressed store, hash-verified

14 * @param {string} [topic]
15 */
16function help(topic) {
17 if (!process.exitCode) process.exitCode = 127;
18
19 if (topic) {
20 let helpFile = path.join(__dirname,
21 '../doc/' + topic.toUpperCase() + '.md');
22 let helpText;
23 try {
24 helpText = fs.readFileSync(helpFile, 'utf8');
25 } catch (e) {
26 Error.throwIfNot(Error.ENOENT, e, 'Failed to read help file: ' + helpFile);
27 }
28
29 if (helpText) {
30 helpText = helpText.replace(/```[\w+-]*/g, '');
31 helpText = wrapLines(helpText, process.stdout.columns);
32 return helpText;
33 }
34 }
35
36 return [
37 'NVS (Node Version Switcher) usage',
38 '',
39 'nvs help <command> Get detailed help for a command',
40 'nvs install Initialize your profile for using NVS',
41 'nvs --version Display the NVS tool version',
42 '',
43 'nvs menu Launch an interactive menu',
44 '',
45 'nvs add <version> Download and extract a node version',
46 'nvs rm <version> Remove a node version',
47 'nvs migrate <fromver> [tover] Migrate global modules',
48 'nvs upgrade [fromver] Upgrade to latest patch of major version',
49 '',
50 'nvs use [version] ' + (canUpdateEnv
51 ? 'Use a node version in the current shell'
52 : '(Not available, source nvs.sh instead)'),
53 'nvs auto [on/off] ' + (canUpdateEnv
54 ? 'Automatically switch based on cwd'
55 : '(Not available, source nvs.sh instead)'),
56 'nvs run <ver> <js> [args...] Run a script using a node version',
57 'nvs exec <ver> <exe> [args...] Run an executable using a node version',
58 'nvs which [version] Show the path to a node version binary',
59 '',
60 'nvs ls [filter] List local node versions',
61 'nvs ls-remote [filter] List node versions available to download',
62 'nvs outdated List local node versions and available updates',
63 '',
64 'nvs link [version] Link a version as the default',
65 'nvs unlink [version] Remove links to a default version',
66 '',
67 'nvs alias [name] [value] Set or recall aliases for versions',
68 'nvs remote [name] [uri] Set or recall download base URIs',
69 '',
70 'A version string consists of a semantic version number or version label',
71 '("lts" or "latest"), optionally preceeded by a remote name, optionally',
72 'followed by an architecture, separated by slashes.',
73 'Examples: "lts", "4.6.0", "6.3.1/x86", "node/6.7.0/x64"',

Callers 1

doCommandFunction · 0.85

Calls 1

wrapLinesFunction · 0.85

Tested by

no test coverage detected