Skip to content

Commit beb67ee

Browse files
author
Priyesh Padmavilasom
committed
update pubsub example
1 parent e01e648 commit beb67ee

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

‎examples/_pubsub/README.md‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,32 @@ Now that tcli's reusable packages live under `pkg/` (instead of `internal/`),
1414
To add pubsub as a module, do the following
1515
- add the module definition from modules.yaml to your tools/modules.yaml
1616
- copy `pubsub.json` to `tools/data`
17-
- blank-import the `pubsub` package from your own `main` (or from
18-
`cmd/main.go` if you're building tcli directly) so its `init()`
19-
registers the `sqs`/`sns` command classes:
17+
- blank-import the `pubsub` package as shown below
2018

2119
```go
20+
package main
21+
2222
import (
23-
_ "github.com/hpinc/tcli/examples/_pubsub/cmd" // registers sqs/sns
24-
"github.com/hpinc/tcli/pkg/env"
23+
"os"
24+
25+
// Blank-import registers the "file" command class with tcli's command
26+
// registry via its init().
27+
_ "github.com/hpinc/tcli/examples/_pubsub/cmd" // registers sqs/sns
28+
"github.com/hpinc/tcli/pkg/env"
2529
)
30+
31+
func main() {
32+
if err := env.Run(); err != nil {
33+
os.Exit(1)
34+
}
35+
}
2636
```
2737

2838
### Test it out
2939

3040
List supported commands
3141
```console
32-
$ TCLI_CONFIG_ROOT=tools go run cmd/main.go pubsub
42+
$ TCLI_CONFIG_ROOT=tools go run main.go pubsub
3343
Please specify a command. Supported commands are:
3444
- send_sns send sns message
3545

@@ -38,7 +48,7 @@ Please specify a command. Supported commands are:
3848

3949
Get help on commands
4050
```console
41-
$ TCLI_CONFIG_ROOT=tools go run cmd/main.go pubsub send_sns -help
51+
$ TCLI_CONFIG_ROOT=tools go run main.go pubsub send_sns -help
4252
Usage of send_sns:
4353
-arn string
4454
arn (default "arn:aws:sns:us-east-1:000000000000:dev")

0 commit comments

Comments
 (0)