@oclif/plugin-search
Advanced tools
Comparing version 1.1.4 to 1.1.5-dev.0
@@ -7,4 +7,5 @@ /* | ||
*/ | ||
import { Command, loadHelpClass, toConfiguredId, toStandardizedId } from '@oclif/core'; | ||
import { Command, loadHelpClass, toConfiguredId, toStandardizedId, ux } from '@oclif/core'; | ||
import autocomplete from 'inquirer-autocomplete-standalone'; | ||
import readline from 'node:readline'; | ||
export default class Search extends Command { | ||
@@ -14,2 +15,5 @@ static description = 'Once you select a command, hit enter and it will show the help for that command.'; | ||
async run() { | ||
this.log(`Interactively search the catalog of ${this.config.bin} commands. | ||
Use ${ux.colorize('bold', '↑')} and ${ux.colorize('bold', '↓')} keys or type to search. Press ${ux.colorize('bold', 'ESC')} to exit. | ||
`); | ||
const commandChoices = this.config.commands | ||
@@ -26,6 +30,6 @@ .filter((c) => !c.hidden && !c.aliases.includes(c.id)) | ||
}); | ||
const command = await autocomplete({ | ||
const commandPromise = autocomplete({ | ||
emptyText: 'Nothing found!', | ||
message: 'Search for a command', | ||
pageSize: 10, | ||
pageSize: Math.floor(process.stdout.rows < 20 ? process.stdout.rows / 2 : 10), | ||
async source(input) { | ||
@@ -35,2 +39,18 @@ return input ? commandChoices.filter((c) => c.name.includes(input)) : commandChoices; | ||
}); | ||
readline.emitKeypressEvents(process.stdin); | ||
process.stdin.setRawMode(true); | ||
process.stdin.on('keypress', (_, key) => { | ||
if (key.name === 'escape') { | ||
commandPromise.cancel(); | ||
} | ||
}); | ||
const command = await commandPromise | ||
.catch((error) => { | ||
if (error.message === 'Prompt was canceled') | ||
return; | ||
throw error; | ||
}) | ||
.then((result) => result); | ||
if (!command) | ||
return; | ||
const Help = await loadHelpClass(this.config); | ||
@@ -37,0 +57,0 @@ const help = new Help(this.config, this.config.pjson.oclif.helpOptions ?? this.config.pjson.helpOptions); |
@@ -29,3 +29,3 @@ { | ||
}, | ||
"version": "1.1.4" | ||
"version": "1.1.5-dev.0" | ||
} |
{ | ||
"name": "@oclif/plugin-search", | ||
"version": "1.1.4", | ||
"version": "1.1.5-dev.0", | ||
"description": "A command for searching commands", | ||
@@ -29,4 +29,4 @@ "author": "Salesforce", | ||
"mocha": "^10.4.0", | ||
"oclif": "^4.13.2", | ||
"prettier": "^3.3.1", | ||
"oclif": "^4.13.6", | ||
"prettier": "^3.3.2", | ||
"shx": "^0.3.3", | ||
@@ -33,0 +33,0 @@ "ts-node": "^10.9.2", |
@@ -25,3 +25,3 @@ # @oclif/plugin-search | ||
$ @oclif/plugin-search (--version) | ||
@oclif/plugin-search/1.1.4 linux-x64 node-v20.14.0 | ||
@oclif/plugin-search/1.1.5-dev.0 linux-x64 node-v20.14.0 | ||
$ @oclif/plugin-search --help [COMMAND] | ||
@@ -53,3 +53,3 @@ USAGE | ||
_See code: [src/commands/search.ts](https://github.com/oclif/plugin-search/blob/v1.1.4/src/commands/search.ts)_ | ||
_See code: [src/commands/search.ts](https://github.com/oclif/plugin-search/blob/v1.1.5-dev.0/src/commands/search.ts)_ | ||
<!-- commandsstop --> | ||
@@ -56,0 +56,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7969
93
1