Skip to content

Added stdin handling for messages #1

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ Klient napisany w bashu, pozwalający na wysyłanie wiadomości SMS w serwisie S

```bash
$ ./smsapi sms send --username LOGIN --password PASS 48xxxyyyzzz,48zzzyyyxxx "Hello world"
$ echo Hello world | ./smsapi sms send --username LOGIN --password PASS 48xxxyyyzzz,48zzzyyyxxx
```

```bash
$ ./smsapi
Usage: smsapi sms send [OPTIONS] <to> <message>
Usage: smsapi sms send [OPTIONS] <to> <message> OR echo message | smsapi sms send [OPTIONS] <to>
Options:
--username <string>
--password <password> md5 api password
Expand Down
4 changes: 2 additions & 2 deletions smsapi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ URI="https://ssl.smsapi.pl/api/"

help() {

echo "Usage: smsapi sms send [OPTIONS] <to> <message>"
echo "Usage: smsapi sms send [OPTIONS] <to> <message> OR echo message | smsapi sms send [OPTIONS] <to>"

echo "Options:
--username <string>
Expand Down Expand Up @@ -98,7 +98,7 @@ sms_send() {
params[${#params[@]}]=username=$(rawurlencode "$USERNAME")
params[${#params[@]}]=password=$(rawurlencode "$PASSWORD")
params[${#params[@]}]=to=$(rawurlencode "$1")
params[${#params[@]}]=message=$(rawurlencode "$2")
params[${#params[@]}]=message=$(rawurlencode "${2:-$(cat)}")

if [ ! -z ${OPTIONS[normalize]} ] && [ ${OPTIONS[normalize]} -eq 1 ]; then
params[${#params[@]}]="normalize=1"
Expand Down