gitmoji-cli icon indicating copy to clipboard operation
gitmoji-cli copied to clipboard

Multiline message support

Open jfstgermain opened this issue 7 years ago • 9 comments

Hello @carloscuesta!

Issue: Multiline message do not seem to be supported

ubuntu 18.04: gitmoji-cli 1.9.2: node 10.14:

Awesome module! It would be great if multiline messages were supported!

jfstgermain avatar Dec 06 '18 16:12 jfstgermain

how about, just like when we used to send emails from the command line, when finished with your message you enter a single dot on it's own line

? Enter the commit message (finish with a single dot on its own line):
[cursor]message message message message [carriage return]
next line next line next line [carriage return]
I've got more to say [carriage return]
and I'll keep saying it until I do this… [carriage return]
.

the final carriage return after the dot proceeds to the next gitmoji section. retro and elegant.

silent-e avatar Jan 03 '19 18:01 silent-e

@silent-e that could be nice, but how should it work if one pastes some text? Also, wouldn't that option prevent from having a (legit) line with just a dot, in the commit message?

I came here because in my case I already had the (long) commit message written somewhere. I tried to paste it in the commit message, but just the first line is being taken and all the rest is skipped; additionally, it wrongly puts the last line of the message in the "Issue / PR reference".

My use case was me trying to git commit --amend (after a gitmoki -i), but gitmoji is called again and asks me to choose and type everything again, rather than going straight to the message editing or proposing the commit message that is already present.

Pictor13 avatar Feb 23 '19 23:02 Pictor13

Ran into a similar need for multiline commit messages.

Here are options I have been exploring to add to gitmoji:

  1. Multiline input for the message prompt
    • two ways to "end" the message: ctrl + d, with single '.'
    • inquirer` currently does not support multiline messages, so we will have to try and get a PR merged or fork until they can.
  2. Pop open an external editor on the commit message step
  3. Pop open an external editor for commit title and message (prepend emoji after)
    • inquirer has an editor option, but it doesn't seem to work with multiple prompts. I get it to open the editor, but it moves on to the next prompt before the editor returns with the message.
  4. Trickery with commit.template (set commit.template with emoji, git commit, unset after).
    • this is a last ditch effort that I thought might work. I want the simplicity of using gitmoji without a hook or some other complex process.

I have started building 1-3 allowing for configurability.

I will open a PR in the next few days once I have something working.

borwahs avatar Feb 25 '19 06:02 borwahs

Ideally we should implement the multiline support through inquirer, even If they still don't support it, basically to avoid doing hacky things 😄

carloscuesta avatar Feb 25 '19 09:02 carloscuesta

Ideally we should implement the multiline support through inquirer, even If they still don't support it, basically to avoid doing hacky things 😄

👍 I don't plan to go the hacky route. It was more an exercise in a quick solution locally so I can use it with multiline commits.

  1. Multiline input for the message prompt
  • two ways to "end" the message: ctrl + d, with single '.'
  • inquirer` currently does not support multiline messages, so we will have to try and get a PR merged or fork until they can.

Initially I thought we would need to get multiline support into inquirer. They allow for custom prompts that we can register at runtime. I am going to build a prompt that works with inquirer as multiline and see if I run into any issues.

I'd like to support:

  1. copy + paste into message
  2. ctrl + d to end prompt for message
  3. single . or other identifier to end commit message
  1. Pop open an external editor on the commit message step* Pop open an external editor for commit title and message (prepend emoji after)
  2. inquirer has an editor option, but it doesn't seem to work with multiple prompts. I get it to open the editor, but it moves on to the next prompt before the editor returns with the message.

I did some research on the external editor support with inquirer and it looks to be broken. Going to open an issue there but that might be a long term solution.

borwahs avatar Feb 25 '19 23:02 borwahs

support \n line breaks like commitizen ?

gee1k avatar May 28 '19 02:05 gee1k

make the behavior configurable, both as a default in the config file, but also an overriding flag.

Implementation

If you pass --edit you'll be dropped into your user defined editor to create the longer commit body (pre-filled with everything else that's set prior)

Look at the git config for core.editor and use that defined program to write the commit message (which has been pre-filled with everything set prior). You can then fall back to looking for environment variables VISUAL or EDITOR with a hardcoded fallback to vi. Similar to how you can do this with git.

To maintain backwards compatibility, without flags, support single line messages (kind of like git -m).

Users can create bash aliases, or change the configuration to support a default behavior if they wish.

Note, that if the default behavior can be set to --edit behavior in the config, then it would would be also useful to have a --no-edit CLI option, to override the config file.

ghostsquad avatar Feb 29 '20 21:02 ghostsquad

Still no way to support multiline?

thinh105 avatar Sep 06 '20 16:09 thinh105

how about, just like when we used to send emails from the command line, when finished with your message you enter a single dot on it's own line

? Enter the commit message (finish with a single dot on its own line):
[cursor]message message message message [carriage return]
next line next line next line [carriage return]
I've got more to say [carriage return]
and I'll keep saying it until I do this… [carriage return]
.

the final carriage return after the dot proceeds to the next gitmoji section. retro and elegant.

I support this suggestion, but for making it more intuitive, keep asking for a message until a blank string is submitted. That way you have an "infinite" number of extra message lines, but if you want none, you just press enter to submit a blank line.

Nixxen avatar Feb 14 '22 10:02 Nixxen