Zhengqbbb / cz-git

cz-git | czg 🛠️ DX first and more engineered, lightweight, customizable, standard output format Commitizen adapter and CLI
https://cz-git.qbb.sh
MIT License
1.13k stars 41 forks source link

[Feature Request] Remove extra \n after words. #152

Closed SpeedySH closed 10 months ago

SpeedySH commented 10 months ago

💭 Describe the feature

First of all thanks for such a great tool! The point of the request is that if we in any of the messages (where "|" or any other hyphenation character is allowed), use it at the end, and maybe even in a row, it causes unexpected problems (multiple line breaks). I'm writing a tool for parsing commits, and this is one of the problems I'm thinking about how to solve, because "foolproofing" should still be included.

💡 Proposed Solution

Prohibit the use of line breaks at the beginning of messages and at the end. Examples: The input: | || || || | my message ||||||| should be converted to: my message

The input: | || || || | my message ||||||| my extra message should be converted to:

my message
my extra message

(No extra line breaks, no extra spaces)

Zhengqbbb commented 10 months ago

I appreciate hearing your feedback. Unfortunately, I won't be handling this request.

This should be the message for the body and BREAKCHANGE.

  1. I have performed a simple processing, using trim().
  2. You may not want to have too many line breaks. However, some people may have such a requirement, hoping to separate messages with line breaks in the body. As a tool provider, I cannot interfere too much with the message format.
  3. If possible, you can use formatMessageCB for parsing on your own.
formatMessageCB: ({ defaultHeader, body }) => {
      let res = defaultHeader
      if (body) {
        res += '\n'
        res += body
          .split('\n')
          .map((line) => {
              // do something for line like
             return line === '\n' ? '' : line
          })
          .join('\n')
      }
      return res
    },
SpeedySH commented 10 months ago

I appreciate hearing your feedback. Unfortunately, I won't be handling this request.

This should be the message for the body and BREAKCHANGE.

  1. I have performed a simple processing, using trim().
  2. You may not want to have too many line breaks. However, some people may have such a requirement, hoping to separate messages with line breaks in the body. As a tool provider, I cannot interfere too much with the message format.
  3. If possible, you can use formatMessageCB for parsing on your own.
formatMessageCB: ({ defaultHeader, body }) => {
      let res = defaultHeader
      if (body) {
        res += '\n'
        res += body
          .split('\n')
          .map((line) => {
              // do something for line like
             return line === '\n' ? '' : line
          })
          .join('\n')
      }
      return res
    },

Thanks! I close this request