From 024b150b430322cb52d970e045b5b77380866ee4 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 1 Jun 2021 10:14:21 +0000 Subject: [PATCH] feat(service): add service line --- service/line/line.go | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/service/line/line.go b/service/line/line.go index 80ec711..0005f25 100644 --- a/service/line/line.go +++ b/service/line/line.go @@ -13,11 +13,11 @@ import ( // Line struct holds data parsed via flags for the service type Line struct { - ChanSecret string - ChanAccessToken string - Message string - Receivers string - Title string + Secret string + Token string + Message string + Receivers string + Title string } // Send parses values from *cli.context and returns a *cli.Command. @@ -26,24 +26,26 @@ type Line struct { func Send() *cli.Command { var lineOpts Line return &cli.Command{ - Name: "line", - Usage: "Send message to line messenger", - Description: `Line messenger uses a channel secret and a channel access token to authenticate & send messages through line to various receivers. Multiple receiver IDs can be used separated by comma ','. All configuration options are also available via environment variables.`, - UsageText: "pingme line --channelsecret '123' --channelaccesstoken '123' --msg 'some message' --receivers '123,456,789'", + Name: "line", + Usage: "Send message to line messenger", + Description: `Line messenger uses a channel secret and +a channel access token to authenticate & send messages +through line to various receivers.`, + UsageText: "pingme line --secret '123' --token '123' --msg 'some message' --receivers '123,456,789'", Flags: []cli.Flag{ &cli.StringFlag{ - Destination: &lineOpts.ChanSecret, - Name: "channelsecret", + Destination: &lineOpts.Secret, + Name: "secret", Required: true, Usage: "Channel secret.", - EnvVars: []string{"LINE_CHANNELSECRET"}, + EnvVars: []string{"LINE_SECRET"}, }, &cli.StringFlag{ - Destination: &lineOpts.ChanAccessToken, - Name: "channelaccesstoken", + Destination: &lineOpts.Token, + Name: "token", Required: true, Usage: "Channel access token.", - EnvVars: []string{"LINE_CHANNELACCESSTOKEN"}, + EnvVars: []string{"LINE_TOKEN"}, }, &cli.StringFlag{ Destination: &lineOpts.Message, @@ -69,7 +71,7 @@ func Send() *cli.Command { }, Action: func(ctx *cli.Context) error { notifier := notify.New() - lineSvc, err := line.New(lineOpts.ChanSecret, lineOpts.ChanAccessToken) + lineSvc, err := line.New(lineOpts.Secret, lineOpts.Token) if err != nil { return err }