@oclif/plugin-search 1.1.4 → 1.1.5-dev.1
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/README.md +2 -2
- package/dist/commands/search.js +29 -3
- package/oclif.manifest.json +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ $ npm install -g @oclif/plugin-search
|
|
|
22
22
|
$ @oclif/plugin-search COMMAND
|
|
23
23
|
running command...
|
|
24
24
|
$ @oclif/plugin-search (--version)
|
|
25
|
-
@oclif/plugin-search/1.1.
|
|
25
|
+
@oclif/plugin-search/1.1.5-dev.1 linux-x64 node-v20.14.0
|
|
26
26
|
$ @oclif/plugin-search --help [COMMAND]
|
|
27
27
|
USAGE
|
|
28
28
|
$ @oclif/plugin-search COMMAND
|
|
@@ -49,7 +49,7 @@ DESCRIPTION
|
|
|
49
49
|
Once you select a command, hit enter and it will show the help for that command.
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
_See code: [src/commands/search.ts](https://github.com/oclif/plugin-search/blob/v1.1.
|
|
52
|
+
_See code: [src/commands/search.ts](https://github.com/oclif/plugin-search/blob/v1.1.5-dev.1/src/commands/search.ts)_
|
|
53
53
|
<!-- commandsstop -->
|
|
54
54
|
|
|
55
55
|
# Contributing
|
package/dist/commands/search.js
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
* Licensed under the BSD 3-Clause license.
|
|
5
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
6
|
*/
|
|
7
|
-
import { Command, loadHelpClass, toConfiguredId, toStandardizedId } from '@oclif/core';
|
|
7
|
+
import { Command, loadHelpClass, toConfiguredId, toStandardizedId, ux } from '@oclif/core';
|
|
8
|
+
import ansiEscapes from 'ansi-escapes';
|
|
8
9
|
import autocomplete from 'inquirer-autocomplete-standalone';
|
|
10
|
+
import readline from 'node:readline';
|
|
9
11
|
export default class Search extends Command {
|
|
10
12
|
static description = 'Once you select a command, hit enter and it will show the help for that command.';
|
|
11
13
|
static summary = 'Search for a command.';
|
|
12
14
|
async run() {
|
|
15
|
+
this.log(`Use ${ux.colorize('bold', '↑')} and ${ux.colorize('bold', '↓')} keys or type to search. Press ${ux.colorize('bold', 'ESC')} to exit.\n`);
|
|
13
16
|
const commandChoices = this.config.commands
|
|
14
17
|
.filter((c) => !c.hidden && !c.aliases.includes(c.id))
|
|
15
18
|
.sort((a, b) => a.id.localeCompare(b.id))
|
|
@@ -21,14 +24,37 @@ export default class Search extends Command {
|
|
|
21
24
|
value: name,
|
|
22
25
|
};
|
|
23
26
|
});
|
|
24
|
-
const
|
|
27
|
+
const pageSize = Math.floor(process.stdout.rows < 20 ? process.stdout.rows / 2 : 10);
|
|
28
|
+
const commandPromise = autocomplete({
|
|
25
29
|
emptyText: 'Nothing found!',
|
|
26
30
|
message: 'Search for a command',
|
|
27
|
-
pageSize
|
|
31
|
+
pageSize,
|
|
28
32
|
async source(input) {
|
|
29
33
|
return input ? commandChoices.filter((c) => c.name.includes(input)) : commandChoices;
|
|
30
34
|
},
|
|
31
35
|
});
|
|
36
|
+
function cancel() {
|
|
37
|
+
commandPromise.cancel();
|
|
38
|
+
// erase the list of commands
|
|
39
|
+
process.stdout.write(ansiEscapes.eraseLines(pageSize + 3));
|
|
40
|
+
}
|
|
41
|
+
readline.emitKeypressEvents(process.stdin);
|
|
42
|
+
process.stdin.setRawMode(true);
|
|
43
|
+
process.stdin.on('keypress', (_, key) => {
|
|
44
|
+
if (key.name === 'escape')
|
|
45
|
+
cancel();
|
|
46
|
+
if (key.name === 'c' && key.ctrl)
|
|
47
|
+
cancel();
|
|
48
|
+
});
|
|
49
|
+
const command = await commandPromise
|
|
50
|
+
.catch((error) => {
|
|
51
|
+
if (error.message === 'Prompt was canceled')
|
|
52
|
+
return;
|
|
53
|
+
throw error;
|
|
54
|
+
})
|
|
55
|
+
.then((result) => result);
|
|
56
|
+
if (!command)
|
|
57
|
+
return;
|
|
32
58
|
const Help = await loadHelpClass(this.config);
|
|
33
59
|
const help = new Help(this.config, this.config.pjson.oclif.helpOptions ?? this.config.pjson.helpOptions);
|
|
34
60
|
return help.showHelp([toStandardizedId(command, this.config)]);
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/plugin-search",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5-dev.1",
|
|
4
4
|
"description": "A command for searching commands",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/plugin-search/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@oclif/core": "^4",
|
|
9
|
+
"ansi-escapes": "^7.0.0",
|
|
9
10
|
"inquirer-autocomplete-standalone": "^0.8.1"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
@@ -26,8 +27,8 @@
|
|
|
26
27
|
"husky": "^9",
|
|
27
28
|
"lint-staged": "^15",
|
|
28
29
|
"mocha": "^10.4.0",
|
|
29
|
-
"oclif": "^4.13.
|
|
30
|
-
"prettier": "^3.3.
|
|
30
|
+
"oclif": "^4.13.6",
|
|
31
|
+
"prettier": "^3.3.2",
|
|
31
32
|
"shx": "^0.3.3",
|
|
32
33
|
"ts-node": "^10.9.2",
|
|
33
34
|
"typescript": "^5.4.5"
|