-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathls_targets.go
41 lines (35 loc) · 941 Bytes
/
ls_targets.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cliaws
import (
"context"
"fmt"
"github.com/alexflint/go-arg"
"github.com/aws/aws-sdk-go/aws"
"github.com/nathants/libaws/lib"
)
func init() {
lib.Commands["events-ls-targets"] = eventsLsTargets
lib.Args["events-ls-targets"] = eventsLsTargetsArgs{}
}
type eventsLsTargetsArgs struct {
RuleName string `arg:"positional,required"`
BusName string `arg:"positional" default:"" help:"specify name to target a bus other than the default bus"`
}
func (eventsLsTargetsArgs) Description() string {
return "\nlist event targets\n"
}
func eventsLsTargets() {
var args eventsLsTargetsArgs
arg.MustParse(&args)
var busName *string
if args.BusName != "" {
busName = aws.String(args.BusName)
}
ctx := context.Background()
targets, err := lib.EventsListRuleTargets(ctx, args.RuleName, busName)
if err != nil {
lib.Logger.Fatal("error: ", err)
}
for _, target := range targets {
fmt.Println(lib.Pformat(target))
}
}