cli
cli copied to clipboard
[Documentation cli 2.0.0] Example to send a message with cli (Plain Text and Markdown)
Hello. I have my problems to understand the doku. ;-) I will give some examples to send a message from bash.
As Mardown: Value of CR are two spaces and carriage return!
printf -v CR " \n" # Fill variable $CR
./gotify-cli-linux-amd64 p -p 0 --url "https://mydomain.com/gotify" --token "Axxxxxxxxxxxxxx" --contentType "text/markdown" -t "Title" "FirstLine${CR}**SecondLine**${CR}\*\*ThirdLine\*\*"
Result:
FirstLine SecondLine **ThirdLine**
As Plain Text: Value of CR is only carriage return.
printf -v CR "\n" # Fill variable $CR
./gotify-cli-linux-amd64 p -p 0 --url "https://mydomain.com/gotify" --token "Axxxxxxxxxxxxxx" --contentType "text/plain" -t "Title" "FirstLine${CR}**SecondLine**"
Result:
FirstLine **SecondLine**
Where exactly is the ambiguity? With text/plain the text just get rendered as text, therefore only a "\n" is needed. Markdown uses a markdown renderer which implements a certain markdown specification. This markdown spec defines that a single linebreak is " \n".
Yes you are right. :-) There are not really any problem, BUT to find and understand this details in documentation is difficult for people who just want to use gotify. ;-)
My contribution is just an information for people who has the same problems as i. Since I unfortunately don't know how to add something there, I have added it here. Normally my information should be moved to documentation (Area: Examples). ;-)
Sorry for this way, but better at the wrong place than at no place. ;-)
I think for those who just want to get it working, they would not bother to use the markdown feature either, and from my point of view, it is evident that a "\n" should be used to send a newline when the message is rendered as plain text.
On the one hand you are right, but on the other hand where to put the "\n"??
Have a look here please:
This is easy. Typically bash/linux with "\n" within the string.
echo -e "FirstLine\nSecondLine"
FirstLine SecondLine
But this does not work! The in-string "\n" is send as characters.
./gotify-cli-linux-amd64 p -p 0 --url "https://mydomain.com/gotify" --token "Axxxxxxxxxxxxxx" --contentType "text/plain" -t "Title" "FirstLine\nSecondLine"
FirstLine\nSecondLine
You have to do it like this with a use of a variable or pipe:
printf -v CR "\n"
./gotify-cli-linux-amd64 p -p 0 --url "https://mydomain.com/gotify" --token "Axxxxxxxxxxxxxx" --contentType "text/plain" -t "Title" "FirstLine${CR}SecondLine"
or
echo -e "FirstLine\nSecondLine" | ./gotify-cli-linux-amd64 p -p 0 --url "https://mydomain.com/gotify" --token "Axxxxxxxxxxxxxx" --contentType "text/plain" -t "Title"
FirstLine SecondLine
It took me hours to figure that out and I don't want others to have to search that long. ;-) If you document it, you can leave it like this in the code. Good documentation and examples are helpful. ;-) Thanks.
I think this is more of bash usage & trick rather than a problem regarding how to use gotify.
If you really need this, I think we can open up a dedicated section to include these "tips" while using gotify.
/cc @jmattheis
You are right of course. This is not a problem of gotify, this is a problem of all users looking for a (quick) working solution. ;-)
So i will help users to find a quick working solution. A Section with "Tips" or "Examples" would be very helpful from my point. A quick start with working examples is more often helpful than reading long and unkown (deep and dark) documention. ;-)
We can add documentation for this to gotify/website, however in gotify/cli we can fix this behavior and just see \n as a linebreak, see above pr.