Feature Request: trim whitespace, allow command embedding
See original GitHub issueCurrently, any trailing whitespace (or at least trailing \r\n) attaches to what it proceeds, making equality tests fail. As a result, this
/hello-world
dispatches the hello-world
demo but this
/hello-world
does not. Similarly, if a command takes arguments, then
/command param1
yields JSON
"arg1": "param1\r\n"
Which can cause the command to fail if it is expecting param1
and does not recognize param1
. I would like leading and trailing whitespace trimmed by default, or at least as an option. This comes up in practice when people copy and paste commands, such as when one command says
Next step, choose either:
/operation approve
/operation deny
Going a step further, I would like to allow real comments to be included in the same comment as the ChatOps command. This would allow people to, well, comment on why they are issuing a command. I would simply require the ChatOps command be on a line by itself.
Going one more step, we could allow multiple commands in a comment. That definitely should be something configurable (enabled/disabled), but I would use it if it were an option.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
@peter-evans OK, we disagree about requiring the command to be on the first line, but it is your project, your call, and I can certainly understand your rationale. I won’t try further to convince you to make changes to the implementation, but I will ask you to include a section in the README that explains how ChatOps commands are parsed, as you have explained above. Particularly:
/
must be the first character of the comment./command
appearing anywhere else will not be interpreted as a command.Thank you again for making the whitespace parsing changes promptly and for providing this valuable library in the first place.
@Nuru As I mentioned in this comment, I don’t think it makes any sense to trim newlines from the start of the comment. However, I’ve made another small fix to trim any other types of whitespace around the contents of the first line.