Open sarbbottam opened 8 years ago
Hi @sarbbottam,
I like this idea. Unfortunately it might be difficult to accomplish. We'd likely need to find a way to use the node-color-readline package with Inquirer.js. If we could find that out, then it might be possible. Even then, we'd need the individual commitizen adapters to adopt this feature.
Thanks!
Thanks @jimthedev, wondering if this should be implemented at Inquirer.js, since Inquirer.js owns/handles the prompt.
@sarbbottam Technically we just pass the adapter an instance of Inquirer, so you can ignore that instance and use something completely separate for prompts. If that thing you uses works with node-color-readline then everything should work. Currently most adapters take advantage of Inquirer because it is so simple to implement and covers a high percentage of use cases. I am open to having these changes in the cz-conventional-changelog if you'd like to put in a PR.
@jimthedev let me take a look, will be more than happy to raise a PR, I might need a little guidance.
I guess I should have raised the issue in cz-conventional-changelog.
Sure thing. I'm happy to answer any questions, review code, or point you in the right direction. On Mon, Apr 4, 2016 at 4:06 PM Sarbbottam Bandyopadhyay < notifications@github.com> wrote:
@jimthedev https://github.com/jimthedev let me take a look, will be more than happy to raise a PR, I might need a little guidance.
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/commitizen/cz-cli/issues/178#issuecomment-205497837
Hi @jimthedev,
I am open to having these changes in the cz-conventional-changelog if you'd like to put in a PR.
I guess cz-conventional-changelog/index.js#L67-L71 can pass a transformer function
to Inquirer.js
...
}, {
type: 'input',
name: 'subject',
- message: 'Write a short, imperative tense description of the change:\n'
+ message: 'Write a short, imperative tense description of the change:\n',
+ transformer: function(line) {
+ return line.substring(0, 99) + chalk.red(line.substring(100))
+ }
}, {
....
and
Inquirer.js/lib/prompts/input.js#L55-L70 can invoke this transformer function
Prompt.prototype.render = function (error) {
var bottomContent = '';
var message = this.getQuestion();
if (this.status === 'answered') {
message += chalk.cyan(this.answer);
} else {
- message += this.rl.line;
+ message += reference.to.the.transformer(this.rl.line);
}
if (error) {
bottomContent = chalk.red('>> ') + error;
}
this.screen.render(message, bottomContent);
};
Let me know your thoughts.
@sarbbottam Seems like a good idea. I'm open to it. If you can get a PR landed in Inquirer then I'd be open to this.
@sarbbottam are you still planning to put a PR together for SBoudrias/Inquirer.js#359 to enable this?
I think it would be a very valuable enhancement to cz-cli
to change the color after 50 characters for a "recommended" length and to change it again or prevent typing at the point the short description would be truncated.
My team has been surprised many times where their messages are truncated when reading through previous logs since there is currently no feedback when constructing the commit.
@travi I have been busy, feel free to take it up.
thanks for the update. i'm not sure when i will get a chance to do it, but i will keep it in mind. please feel free if you get a chance before me.
it looks like i never updated this thread with progress that i was able to make. i was able to get the change discussed above accepted into inquirer in https://github.com/SBoudrias/Inquirer.js/issues/359 (pr was https://github.com/SBoudrias/Inquirer.js/pull/642), but i havent found time to leverage that ability to make the contribution back to commitizen to finish this up.
if someone happens to want to pick that up before i can get to it, the documentation to use the formatter/transformer can be found here (under transformer
).
Thanks for the update and the work to get that into Inquirer @travi! Seems like it would be a good one for someone to pick up. I will leave this open as a todo.
Is it possible to change the color of the input beyond certain length?
Somthing like
Thanks!