Skip to content
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
22 changes: 22 additions & 0 deletions bark/bark.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
)
Expand Down Expand Up @@ -94,6 +95,27 @@ func (d *Device) sendData(data url.Values, opts ...Options) error {
if o.ForceCopy {
query.Set("automaticallyCopy", "1")
}
if isNotBlank(o.Level) {
query.Set("level", o.Level)
}
if isNotBlank(o.Subtitle) {
query.Set("subtitle", o.Subtitle)
}
if isNotBlank(o.Group) {
query.Set("group", o.Group)
}
if isNotBlank(o.Action) {
query.Set("action", o.Action)
}
if o.Badge >= 0 {
query.Set("badge", strconv.Itoa(int(o.Badge)))
}
if o.Volume >= 0 {
query.Set("volume", strconv.Itoa(int(o.Volume)))
}
if o.Call {
query.Set("call", "1")
}
}
req.URL.RawQuery = query.Encode()

Expand Down
3 changes: 0 additions & 3 deletions bark/go.mod

This file was deleted.

29 changes: 29 additions & 0 deletions bark/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ type Options struct {
CopyText string
ForceArchive bool
ForceCopy bool

Level string
Subtitle string
Group string
Action string
Badge int32
Volume int32
Call bool
}

func (o Options) String() string {
Expand All @@ -41,5 +49,26 @@ func (o Options) String() string {
if o.ForceCopy {
parts = append(parts, "AutoCopy")
}
if isNotBlank(o.Level) {
parts = append(parts, fmt.Sprintf("Level=%s", o.Level))
}
if isNotBlank(o.Subtitle) {
parts = append(parts, fmt.Sprintf("Subtitle=%s", o.Subtitle))
}
if isNotBlank(o.Group) {
parts = append(parts, fmt.Sprintf("Group=%s", o.Group))
}
if isNotBlank(o.Action) {
parts = append(parts, fmt.Sprintf("Action=%s", o.Action))
}
if o.Badge >= 0 {
parts = append(parts, fmt.Sprintf("Badge=%d", o.Badge))
}
if o.Volume >= 0 {
parts = append(parts, fmt.Sprintf("Volume=%d", o.Volume))
}
if o.Call {
parts = append(parts, "Call")
}
return fmt.Sprintf("(Opt: %s)", strings.Join(parts, ", "))
}
23 changes: 23 additions & 0 deletions cmd/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ var sendCmd = &cobra.Command{
CopyText: copyText,
ForceArchive: forceArchive,
ForceCopy: forceCopy,
Level: level,
Subtitle: subtitle,
Group: group,
Action: action,
Badge: badge,
Volume: volume,
Call: call,
}

for i, dev := range devices {
Expand Down Expand Up @@ -122,6 +129,14 @@ var (
openURL string
forceArchive bool
forceCopy bool

level string
subtitle string
group string
action string
badge int32
volume int32
call bool
)

func init() {
Expand All @@ -134,5 +149,13 @@ func init() {
sendCmd.Flags().StringVarP(&openURL, "url", "u", "", "URL to open")
sendCmd.Flags().BoolVar(&forceArchive, "force-archive", false, "Force to archive notification")
sendCmd.Flags().BoolVar(&forceCopy, "force-copy", false, "Force to copy text")

sendCmd.Flags().StringVarP(&level, "level", "l", "active", "Level: critical, active, timeSensitive, passive")
sendCmd.Flags().StringVarP(&subtitle, "subtitle", "s", "", "Subtitle of notification")
sendCmd.Flags().StringVarP(&group, "group", "g", "", "Group of notification")
sendCmd.Flags().StringVarP(&action, "action", "a", "", "Action of notification: none")
sendCmd.Flags().BoolVarP(&call, "call", "C", false, "Call to replay ringtone")
sendCmd.Flags().Int32VarP(&badge, "badge", "B", 0, "Badge number to show")
sendCmd.Flags().Int32VarP(&volume, "volume", "V", 0, "Volume of ringtone")
//_ = sendCmd.MarkFlagRequired("body")
}
42 changes: 38 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
module github.com/1set/barkme

go 1.16
go 1.18

require (
bitbucket.org/ai69/amoy v0.2.0
bitbucket.org/ai69/colorlogo v0.1.1
github.com/1set/barkme/bark v0.0.0-20210315164954-1c056c857e27
github.com/1set/gut v0.0.0-20201117175203-a82363231997
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.6.0
github.com/spf13/viper v1.13.0
github.com/spf13/viper v1.19.0
go.uber.org/zap v1.23.0
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
)

require (
bitbucket.org/creachadair/shell v0.0.7 // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/aymanbagabas/go-osc52 v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/muesli/termenv v0.13.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.13.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading