-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Initial input values #590
Comments
Any feedback? If so, I'm interested in contributing the feature. |
This would be useful. At the moment it's hard to get default value in the input prompt and edit/modify it (eg. rename file.xxx to file2.xxx etc). To me it'd feel natural if I press TAB, the default value gets written in the input so I can edit it (I'm not sure if you can detect this in the console). |
@czebe yeah, any keypress can be detected. I think using tab to put the default value in is a great idea actually. Would you be interested in preparing a PR? |
@SBoudrias I'll give it a shot, to implement tab complete. |
Any luck with this @renarsvilnis? |
@jonathancochran No, I needed a quick fix, so I just added a prefix |
This would be really useful. My use case is entering dates in a CLI (paper documents) scanning interface. My default value is today's date, such as I know there's datepicker plugins, but text is a bit easier for me. The file renaming example above is really good too. The tab completion idea is nice, but as a basic start without much more work it would be handy just as an option we can specify. |
I'm very interested in this feature, I'd like to use it in my nprr (a sort of npm run + autocomplete) package 😊 |
the |
I ended up solving this a little bit differently. For situations where I want to be able to edit the default value of an This is my code: import inquirer from 'inquirer';
(async ()=>{
const question = {
type: 'input',
name: 'answer',
default: "idk, give it a try",
message: "can you edit the default value?"
}
const prompt = inquirer.prompt([
question
])
const readStream = (prompt.ui as any).rl.input;
readStream.push(question.default);
const {answer} = await prompt;
console.log({answer});
})() note that it this only works if you are asking one question at a time. |
Hi all, the new @inquirer/input allow editing the default value when pressing I'll close this ticket as we don't intend to backport features to the maintenance version. See new release announcement |
I'd like to make a feature request for the ability to have editable default values (maybe call it "initial value"?).
Usage example
In the example gif below instead of copy-pasting the "default" value, that is auto-generated from the given link, I'd like the user to be able to edit the generated value easier.
Maybe there is some hackish way of achieving it now? I tried mutably modifying the given Answers hash within the filter method of the first question, but no luck.
The text was updated successfully, but these errors were encountered: