@oclif/plugin-search 1.1.4 → 1.1.5-dev.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/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.4 linux-x64 node-v20.14.0
25
+ @oclif/plugin-search/1.1.5-dev.0 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.4/src/commands/search.ts)_
52
+ _See code: [src/commands/search.ts](https://github.com/oclif/plugin-search/blob/v1.1.5-dev.0/src/commands/search.ts)_
53
53
  <!-- commandsstop -->
54
54
 
55
55
  # Contributing
@@ -4,12 +4,16 @@
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
8
  import autocomplete from 'inquirer-autocomplete-standalone';
9
+ import readline from 'node:readline';
9
10
  export default class Search extends Command {
10
11
  static description = 'Once you select a command, hit enter and it will show the help for that command.';
11
12
  static summary = 'Search for a command.';
12
13
  async run() {
14
+ this.log(`Interactively search the catalog of ${this.config.bin} commands.
15
+ Use ${ux.colorize('bold', '↑')} and ${ux.colorize('bold', '↓')} keys or type to search. Press ${ux.colorize('bold', 'ESC')} to exit.
16
+ `);
13
17
  const commandChoices = this.config.commands
14
18
  .filter((c) => !c.hidden && !c.aliases.includes(c.id))
15
19
  .sort((a, b) => a.id.localeCompare(b.id))
@@ -21,14 +25,30 @@ export default class Search extends Command {
21
25
  value: name,
22
26
  };
23
27
  });
24
- const command = await autocomplete({
28
+ const commandPromise = autocomplete({
25
29
  emptyText: 'Nothing found!',
26
30
  message: 'Search for a command',
27
- pageSize: 10,
31
+ pageSize: Math.floor(process.stdout.rows < 20 ? process.stdout.rows / 2 : 10),
28
32
  async source(input) {
29
33
  return input ? commandChoices.filter((c) => c.name.includes(input)) : commandChoices;
30
34
  },
31
35
  });
36
+ readline.emitKeypressEvents(process.stdin);
37
+ process.stdin.setRawMode(true);
38
+ process.stdin.on('keypress', (_, key) => {
39
+ if (key.name === 'escape') {
40
+ commandPromise.cancel();
41
+ }
42
+ });
43
+ const command = await commandPromise
44
+ .catch((error) => {
45
+ if (error.message === 'Prompt was canceled')
46
+ return;
47
+ throw error;
48
+ })
49
+ .then((result) => result);
50
+ if (!command)
51
+ return;
32
52
  const Help = await loadHelpClass(this.config);
33
53
  const help = new Help(this.config, this.config.pjson.oclif.helpOptions ?? this.config.pjson.helpOptions);
34
54
  return help.showHelp([toStandardizedId(command, this.config)]);
@@ -26,5 +26,5 @@
26
26
  ]
27
27
  }
28
28
  },
29
- "version": "1.1.4"
29
+ "version": "1.1.5-dev.0"
30
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oclif/plugin-search",
3
- "version": "1.1.4",
3
+ "version": "1.1.5-dev.0",
4
4
  "description": "A command for searching commands",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/plugin-search/issues",
@@ -26,8 +26,8 @@
26
26
  "husky": "^9",
27
27
  "lint-staged": "^15",
28
28
  "mocha": "^10.4.0",
29
- "oclif": "^4.13.2",
30
- "prettier": "^3.3.1",
29
+ "oclif": "^4.13.6",
30
+ "prettier": "^3.3.2",
31
31
  "shx": "^0.3.3",
32
32
  "ts-node": "^10.9.2",
33
33
  "typescript": "^5.4.5"