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

Added human flag for reminder list and reminder info #109

Open
wants to merge 1 commit 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
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ Usage:
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--reminder|rm] [--trace|-x]

slack reminder info [reminder]
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--reminder|rm] [--trace|-x]
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--reminder|rm] [--human] [--trace|-x]

slack reminder list
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--human] [--trace|-x]

slack snooze end
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]
Expand Down Expand Up @@ -363,17 +363,20 @@ $ slack presence active
```console
$ # List reminders:
$ slack reminder list

$ # List reminders in human readable form via options (no JSON output)
$ slack reminder list --human
```

### `reminder add`

```console
$ # Add reminder via prompts:
$ slack reminder add
$

$ # Add reminder via arguments:
$ slack reminder add '@slackbot' 'lunch' 1526995300
$

$ # Add reminder via options:
$ slack reminder add --user="@slackbot" --text="lunch" --time=1526995300
```
Expand All @@ -383,10 +386,10 @@ $ slack reminder add --user="@slackbot" --text="lunch" --time=1526995300
```console
$ # Complete reminder via prompts:
$ slack reminder complete
$

$ # Complete reminder via arguments:
$ slack reminder complete Rm7MGABKT6
$

$ # Complete reminder via options:
$ slack reminder complete --reminder="Rm7MGABKT6"
```
Expand All @@ -396,10 +399,10 @@ $ slack reminder complete --reminder="Rm7MGABKT6"
```console
$ # Complete reminder via prompts:
$ slack reminder delete
$

$ # Complete reminder via arguments:
$ slack reminder delete "Rm7MGABKT6"
$

$ # Complete reminder via options:
$ slack reminder delete --reminder="Rm7MGABKT6"
```
Expand All @@ -409,12 +412,15 @@ $ slack reminder delete --reminder="Rm7MGABKT6"
```console
$ # Info about reminder via prompts:
$ slack reminder info
$

$ # Info about reminder via arguments:
$ slack reminder info "Rm7MGABKT6"
$

$ # Info about reminder via options:
$ slack reminder info --reminder="Rm7MGABKT6"

# Info about reminders in human readable form via options (no JSON output)
$ slack reminder info --human
```

### `presence away`
Expand Down
11 changes: 7 additions & 4 deletions src/slack
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ while (( "$#" )); do
--footer-icon*|-fi*) footericon=${2} ; shift ; shift ;;
--footer=*) footer=${1/--footer=/''} ; shift ;;
--footer*|-ft*) footer=${2} ; shift ; shift ;;
--human) human=${1/--human=/''} ; shift ;;
--image=*) image=${1/--image-url=/''} ; shift ;;
--image*|-im*) image=${2} ; shift ; shift ;;
--monochrome|-m) monochrome='-M' ; shift ;;
Expand Down Expand Up @@ -358,10 +359,10 @@ function help() {
echo ' [--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--reminder|rm] [--trace|-x]'
echo
echo " ${bin} reminder info [reminder]"
echo ' [--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--reminder|rm] [--trace|-x]'
echo ' [--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--reminder|rm] [--human] [--trace|-x]'
echo
echo " ${bin} reminder list"
echo ' [--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]'
echo ' [--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--human] [--trace|-x]'
echo
echo " ${bin} snooze end"
echo ' [--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]'
Expand Down Expand Up @@ -564,15 +565,17 @@ function reminderinfo() {
--data-urlencode "reminder=${reminder}" \
--data-urlencode "token=${token}")

jqify "${msg}"
# If we have a human flag we'll output in a human readable form, otherwise just show the JSON
[ -z "$human" ] && jqify "${msg}" || echo ${msg} | jq -r '.reminder | .text as $text | .complete_ts as $completed | .recurring as $recurring | .id as $id | if $recurring == true then "♲ \($text) (id: \($id))" elif $completed == 0 then "✗ \($text) (id: \($id))" else "✓ \($text) (id: \($id))" end'
}

function reminderlist() {
local msg=$(\
curl -s -X POST https://slack.com/api/reminders.list \
--data-urlencode "token=${token}")

jqify "${msg}"
# If we have a human flag we'll output in a human readable form, otherwise just show the JSON
[ -z "$human" ] && jqify "${msg}" || echo ${msg} | jq -r '.reminders[] | .text as $text | .complete_ts as $completed | .recurring as $recurring | .id as $id | if $recurring == true then "♲ \($text) (id: \($id))" elif $completed == 0 then "✗ \($text) (id: \($id))" else "✓ \($text) (id: \($id))" end'
}

function snoozeend() {
Expand Down