Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation cli 2.0.0] Example to send a message with cli (Plain Text and Markdown) #17

Open
pm-pm opened this issue Apr 16, 2019 · 7 comments
Labels
question Further information is requested

Comments

@pm-pm
Copy link

pm-pm commented Apr 16, 2019

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**

@pm-pm pm-pm changed the title [Doku cli 2.0.0] Example to send a message with cli (Plain Text and Markdown) [Documentation cli 2.0.0] Example to send a message with cli (Plain Text and Markdown) Apr 16, 2019
@jmattheis
Copy link
Member

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

@jmattheis jmattheis added the question Further information is requested label Apr 16, 2019
@pm-pm
Copy link
Author

pm-pm commented Apr 16, 2019

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. ;-)

@eternal-flame-AD
Copy link
Member

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.

@pm-pm
Copy link
Author

pm-pm commented Apr 17, 2019

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.

@eternal-flame-AD
Copy link
Member

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

@pm-pm
Copy link
Author

pm-pm commented Apr 17, 2019

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. ;-)

@jmattheis
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

3 participants