question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: trim whitespace, allow command embedding

See original GitHub issue

Currently, 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:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Nurucommented, Mar 6, 2020

@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.
  • The command extends to the last non-whitespace character on the first line and everything after that is ignored. This allows you to add information about the command to the comment.

Thank you again for making the whitespace parsing changes promptly and for providing this valuable library in the first place.

0reactions
peter-evanscommented, Mar 9, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

feature request: trim whitespace on read · Issue #211 - GitHub
It'd be great to have an option like strip.white=TRUE, or strip_white=BOTH to automatically remove leading or trailing whitespace on import.
Read more >
trimws: Remove Leading/Trailing Whitespace - Rdrr.io
a character string specifying whether to remove both leading and trailing whitespace (default), or only leading ( "left" ) or trailing ( "right"...
Read more >
Trailing spaces in strings (e.g. attribute elements, filter) are ...
By selecting the "Do not trim trailing space" option, these attribute elements should be returned as separate attribute elements.
Read more >
How to Use //go:embed - The Ethically-Trained Programmer
I have previously written about how to use //go:generate . It exists to “to automate the running of tools to generate source code...
Read more >
How to Show or Hide White Space in Word Documents
Because this feature isn't obvious, it can cause problems for users if areas in their document seem to be missing (such as headers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found