Inquirer.js: Prompt.prototype.prefix is not used in getQuestion

Created on 30 Jul 2015  路  14Comments  路  Source: SBoudrias/Inquirer.js

In this line (https://github.com/SBoudrias/Inquirer.js/blob/v0.9.0/lib/prompts/base.js#L169), the call to prefix was changed with:

chalk.green('?')

In version 0.8.5, the prefix function was being used. Is there a reason for not using it anymore?

Thanks!

All 14 comments

Yeah, I'm removing all the crust around the huge classes so it can easily be exported to a standalone module.

Not sure what I want to do about prefixes/suffixes yet.

it would be nice to make prefix and suffix configurable, can that be done in other way?

I agree with this, I don't like having the ? suffix for each question asked, especially when it doesn't go along with my UI. It really should be configurable so I can remove it. @SBoudrias is this something that you'd take a PR for? I'd be happy to do it.

@jsonmaur Well, it depends on the solution implemented.

What do you have in mind?

@SBoudrias Maybe just a messagePrefix option on the question object that would default to ?. Seems like you could just add it as a default at lib/prompts/base.js line 21, then just reference it in Prompt.prototype.getQuestion. But that's from me looking at the code for all of 5 minutes, haha.

That may get tedious to set the prefix on every question, so maybe a second parameter passed to inquirer.prompt could be global options (unless that's reserved for a callback). That could be useful for more than just setting the prefix, such as defining a global validators, etc. Thoughts?

Any update on this? My ideas above may be overkill, but I need to at least hide it. My current solution is really hacky (overriding the getQuestion prototype with my own function).

@jsonmaur maybe we could set it up as a constant inquirer.PREFIX or something similar. Then it could be replaced without too much trouble and without adding extra API surface to the prompt method.

That would work. With that in mind, it would also be nice to provide a way to customize prefixes for other things such as validation error messages, prompt arrows, checkboxes, etc. Maybe a list of several different constants, or having the PREFIX constant accept an object map?

@jsonmaur an object map would be better.

Is this still on the roadmap? I just started using inquirer and customizing the prompt prefix is literally the first thing I wanted to do. ;)

Sorry I got busy and wasn't able to tackle it. Someone else better take a shot at a PR.

I just sent a PR (#571) with something like this. Now you should be able to set prefix/suffix from question options. It could be good to have a function like inquirer.setDefaultPrefix(prefix).

Cheaters never win

571 successfully resolved this issue. Should close this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fuechter picture fuechter  路  3Comments

jahvi picture jahvi  路  6Comments

aydn picture aydn  路  5Comments

dantasfiles picture dantasfiles  路  3Comments

aaronshaf picture aaronshaf  路  7Comments