julienXX / terminal-notifier

Send User Notifications on macOS from the command-line.
Other
6.38k stars 330 forks source link

Fix arguments starting with "-" being unrecognized #189

Closed iRath96 closed 7 years ago

iRath96 commented 7 years ago

First of all, thank you for this amazing gem!

I recently ran into an issue that when passing arguments (like text, title or subtitle) that start with a "-", no notification would be displayed. I traced this bug down to NSUserDefaults, which doesn't like arguments like -title "-xyz" apparently. This PR implements a hack to get around this by inserting a space before such arguments (-title "-xyz" becomes -title " -xyz"). MacOS removes whitespace, so notifications are shown correctly (without the space) in the notification center.

julienXX commented 7 years ago

Thanks a lot @iRath96 ! Could you add a test to validate your PR please if that's not too complicated?

iRath96 commented 7 years ago

@julienXX Added the test case. Let me know if there's anything else you need :)

julienXX commented 7 years ago

Thanks again!