@oclif/plugin-search 1.1.5-dev.0 → 1.1.5-dev.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/README.md +2 -2
- package/dist/commands/search.js +13 -7
- package/oclif.manifest.json +1 -1
- package/package.json +2 -1
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.5-dev.
|
|
25
|
+
@oclif/plugin-search/1.1.5-dev.2 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.5-dev.
|
|
52
|
+
_See code: [src/commands/search.ts](https://github.com/oclif/plugin-search/blob/v1.1.5-dev.2/src/commands/search.ts)_
|
|
53
53
|
<!-- commandsstop -->
|
|
54
54
|
|
|
55
55
|
# Contributing
|
package/dist/commands/search.js
CHANGED
|
@@ -5,15 +5,14 @@
|
|
|
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
7
|
import { Command, loadHelpClass, toConfiguredId, toStandardizedId, ux } from '@oclif/core';
|
|
8
|
+
import ansiEscapes from 'ansi-escapes';
|
|
8
9
|
import autocomplete from 'inquirer-autocomplete-standalone';
|
|
9
10
|
import readline from 'node:readline';
|
|
10
11
|
export default class Search extends Command {
|
|
11
12
|
static description = 'Once you select a command, hit enter and it will show the help for that command.';
|
|
12
13
|
static summary = 'Search for a command.';
|
|
13
14
|
async run() {
|
|
14
|
-
this.log(`
|
|
15
|
-
Use ${ux.colorize('bold', '↑')} and ${ux.colorize('bold', '↓')} keys or type to search. Press ${ux.colorize('bold', 'ESC')} to exit.
|
|
16
|
-
`);
|
|
15
|
+
this.log(ux.colorize('cyan', `Use ${ux.colorize('bold', '↑')} and ${ux.colorize('bold', '↓')} keys or type to search for a command.\nPress ${ux.colorize('bold', 'ENTER')} to view help. Press ${ux.colorize('bold', 'ESC')} to exit.\n`));
|
|
17
16
|
const commandChoices = this.config.commands
|
|
18
17
|
.filter((c) => !c.hidden && !c.aliases.includes(c.id))
|
|
19
18
|
.sort((a, b) => a.id.localeCompare(b.id))
|
|
@@ -25,20 +24,27 @@ Use ${ux.colorize('bold', '↑')} and ${ux.colorize('bold', '↓')} keys or type
|
|
|
25
24
|
value: name,
|
|
26
25
|
};
|
|
27
26
|
});
|
|
27
|
+
const pageSize = Math.floor(process.stdout.rows < 20 ? process.stdout.rows / 2 : 10);
|
|
28
28
|
const commandPromise = autocomplete({
|
|
29
29
|
emptyText: 'Nothing found!',
|
|
30
30
|
message: 'Search for a command',
|
|
31
|
-
pageSize
|
|
31
|
+
pageSize,
|
|
32
32
|
async source(input) {
|
|
33
33
|
return input ? commandChoices.filter((c) => c.name.includes(input)) : commandChoices;
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
|
+
function cancel() {
|
|
37
|
+
commandPromise.cancel();
|
|
38
|
+
// erase the list of commands
|
|
39
|
+
process.stdout.write(ansiEscapes.eraseLines(pageSize + 3));
|
|
40
|
+
}
|
|
36
41
|
readline.emitKeypressEvents(process.stdin);
|
|
37
42
|
process.stdin.setRawMode(true);
|
|
38
43
|
process.stdin.on('keypress', (_, key) => {
|
|
39
|
-
if (key.name === 'escape')
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
if (key.name === 'escape')
|
|
45
|
+
cancel();
|
|
46
|
+
if (key.name === 'c' && key.ctrl)
|
|
47
|
+
cancel();
|
|
42
48
|
});
|
|
43
49
|
const command = await commandPromise
|
|
44
50
|
.catch((error) => {
|
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.5-dev.
|
|
3
|
+
"version": "1.1.5-dev.2",
|
|
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": {
|