Skip to content

Commit 7aa9f61

Browse files
authored
as plain text rendering (#31)
* as plain text rendering * updated documentation
1 parent 93a46b0 commit 7aa9f61

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ updates:
77
interval: daily
88
time: "11:00"
99
open-pull-requests-limit: 10
10+
commit-message:
11+
prefix: "chore(ci)"

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,32 @@ With this plugin, as long as you're logged into the same Cloud Foundry installat
1414

1515
```sh
1616
# get details on a service instance by it's GUID alone
17-
cf rsl -s 4c463943-d421-4f6f-8501-247fba95882d
17+
cf rsl -s 8891ec47-4041-496b-af36-10d89c9513a6
1818

1919
# passing BOSH's default 'service-instance_' prefix is acceptable, too
20-
cf rsl -s service-instance_4c463943-d421-4f6f-8501-247fba95882d
20+
cf rsl -s service-instance_8891ec47-4041-496b-af36-10d89c9513a6
2121

2222
# you can pass '-s service-instance_GUID' multiple times
23-
cf rsl -s service-instance_4c463943-d421-4f6f-8501-247fba95882d -s bbaa77df-52e7-4d6a-8c86-d07a7c93ab82
23+
cf rsl -s service-instance_8891ec47-4041-496b-af36-10d89c9513a6 -s bbaa77df-52e7-4d6a-8c86-d07a7c93ab82
2424

2525
# optionally, multiple different presentation formats can be specified
26-
cf rsl -s xyz --format table (default)
26+
cf rsl -s xyz --format plain-text (default)
27+
cf rsl -s xyz --format table
2728
cf rsl -s xyz --format json
2829

2930
# or both, why not
3031
cf rsl -s xyz --format table --format json
3132
```
3233

34+
`--format plain-text`:
35+
36+
```txt
37+
d6bb8908-a8f8-46b9-9c21-3069cdb939ef
38+
small-redis
39+
grundlework
40+
scratchpad
41+
```
42+
3343
`--format json`:
3444

3545
```json
@@ -68,13 +78,13 @@ If you want to try it out, install it directly from [the github releases tab as
6878

6979
```sh
7080
# osx 64bit
71-
cf install-plugin -f https://github.com/aegershman/cf-reverse-service-lookup-plugin/releases/download/0.6.0/cf-reverse-service-lookup-plugin-darwin
81+
cf install-plugin -f https://github.com/aegershman/cf-reverse-service-lookup-plugin/releases/download/0.7.0/cf-reverse-service-lookup-plugin-darwin
7282

7383
# linux 64bit (32bit and ARM6 also available)
74-
cf install-plugin -f https://github.com/aegershman/cf-reverse-service-lookup-plugin/releases/download/0.6.0/cf-reverse-service-lookup-plugin-amd64
84+
cf install-plugin -f https://github.com/aegershman/cf-reverse-service-lookup-plugin/releases/download/0.7.0/cf-reverse-service-lookup-plugin-amd64
7585

7686
# windows 64bit (32bit also available)
77-
cf install-plugin -f https://github.com/aegershman/cf-reverse-service-lookup-plugin/releases/download/0.6.0/cf-reverse-service-lookup-plugin-windows-amd64.exe
87+
cf install-plugin -f https://github.com/aegershman/cf-reverse-service-lookup-plugin/releases/download/0.7.0/cf-reverse-service-lookup-plugin-windows-amd64.exe
7888
```
7989

8090
## updating and releasing
@@ -83,7 +93,7 @@ cf install-plugin -f https://github.com/aegershman/cf-reverse-service-lookup-plu
8393
- `go mod tidy`
8494
- update the plugin version in `main.go`
8595
- update the `README` install-plugin section to reference the new upcoming release version
86-
- `git tag 0.6.0` -- or whatever version, of course
96+
- `git tag 0.7.0` -- or whatever version, of course
8797
- `git push origin --tags`
8898
- `export GITHUB_TOKEN="xyzabc"`
8999
- `goreleaser release`

Taskfile.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ tasks:
2020
test:
2121
cmds:
2222
- task: install
23-
- cf rsl -s db8dba61-32c7-4834-b94b-b3d61240d47b --format json | jq '.'
24-
- cf rsl -s db8dba61-32c7-4834-b94b-b3d61240d47b --format table --format json
25-
- cf rsl -s db8dba61-32c7-4834-b94b-b3d61240d47b -s db8dba61-32c7-4834-b94b-b3d61240d47b
23+
- cf rsl -s 8891ec47-4041-496b-af36-10d89c9513a6
24+
- cf rsl -s 8891ec47-4041-496b-af36-10d89c9513a6 --format json | jq '.'
25+
- cf rsl -s 8891ec47-4041-496b-af36-10d89c9513a6 --format table --format plain-text --format json
26+
- cf rsl -s 8891ec47-4041-496b-af36-10d89c9513a6 -s 8891ec47-4041-496b-af36-10d89c9513a6
2627
- task: uninstall

cmd/rsl/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (cmd *reverseServiceLookupCmd) GetMetadata() plugin.PluginMetadata {
8787
Name: "cf-reverse-service-lookup-plugin",
8888
Version: plugin.VersionType{
8989
Major: 0,
90-
Minor: 6,
90+
Minor: 7,
9191
Build: 0,
9292
},
9393
Commands: []plugin.Command{
@@ -97,7 +97,7 @@ func (cmd *reverseServiceLookupCmd) GetMetadata() plugin.PluginMetadata {
9797
UsageDetails: plugin.Usage{
9898
Usage: "cf rsl [-s service_instance-xyzabc...]",
9999
Options: map[string]string{
100-
"format": "format to present (options: table,json) (default: table)",
100+
"format": "format to present (options: table,json,plain-text) (default: plain-text)",
101101
"s": "service_instance-GUID to look up. Can be of form 'service_instance-xyzguid123' or just 'xyzguid123'",
102102
"trim-prefix": "if your services are prefixed with something besides BOSH defaults, change this to be the string prefix before the service GUID... also, if you have that use-case, definitely let me know, I'm intrigued. (default: service_instance-)",
103103
},

internal/v2client/presenter.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package v2client
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"io"
67
"log"
8+
"strings"
79

810
"github.com/olekukonko/tablewriter"
911
)
@@ -27,7 +29,7 @@ func NewPresenter(formats []string, serviceReports []ServiceReport, writer io.Wr
2729
// Render -
2830
func (p *Presenter) Render() {
2931
if len(p.formats) == 0 {
30-
p.asTable()
32+
p.asPlainText()
3133
}
3234

3335
for _, f := range p.formats {
@@ -36,10 +38,24 @@ func (p *Presenter) Render() {
3638
p.asTable()
3739
case "json":
3840
p.asJSON()
41+
case "plain-text":
42+
p.asPlainText()
3943
}
4044
}
4145
}
4246

47+
func (p *Presenter) asPlainText() {
48+
for _, report := range p.serviceReports {
49+
fieldsJoined := strings.Join([]string{
50+
report.Service.GUID,
51+
report.Service.Name,
52+
report.Organization.Name,
53+
report.Space.Name,
54+
}, "\n")
55+
fmt.Println(fieldsJoined)
56+
}
57+
}
58+
4359
func (p *Presenter) asTable() {
4460
table := tablewriter.NewWriter(p.writer)
4561
table.SetHeader([]string{

0 commit comments

Comments
 (0)