Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@replit/clui-input
Advanced tools
Readme
@replit/clui-input
implementes the logic for mapping text input to suggestions and a potential run
function.
import input from '@replit/clui-input';
const rootCommand = {
commands: {
open: {
commands: {
sesame: {
run: (args) => {
/* do something */
},
},
},
},
},
};
const update = input({
command: rootCommand,
onUpdate: (updates) => {
/* Update #1: `updates.options` will be
* [
* {
* "value": "open",
* "inputValue": "open",
* "searchValue": "o",
* "cursorTarget": 4
* }
* ]
*/
/* Update #2: `updates.options` will be
* [
* {
* "value": "sesame",
* "inputValue": "open sesame",
* "searchValue": "s",
* "cursorTarget": 12
* }
* ]
*/
},
});
/* Update #1 */
update({ value: 'o', index: 1 });
/* Update #2 */
update({ value: 'open s', index: 6 });
When the input matches a command with a run
function, the onUpdate
callback will include a reference to it.
const update = input({
command: rootCommand,
onUpdate: (updates) => {
// call or store reference to `updates.run` based on user interaction
},
});
update({ value: 'open sesame', index: 6 });
@replit/clui-input
a framework agnostic primitive that can be wrapped by more specific framework or application code (like a react hook). If using react you will most likey want to keep the result of onUpdate
in a state object. For managing dropdown selection UX I highly recommend downshift.
FAQs
A utility library for building CLI style interfaces with autocomplete
The npm package @replit/clui-input receives a total of 15,616 weekly downloads. As such, @replit/clui-input popularity was classified as popular.
We found that @replit/clui-input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.