Skip to content

Commit 0208b21

Browse files
joemasilotticlaude
andcommitted
Switch to /webhooks/cli/ endpoint and pingrb configure
CLI is now its own source type on the Rails side with parser_type=cli, served at /webhooks/cli/<token>. Subcommand renamed from `config` to `configure` to match the install partial's documented setup flow. Help text and error messages drop the "Custom source" framing since CLI is the source now. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6472397 commit 0208b21

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ go install github.com/ruby-native/pingrb-cli@latest
1717
## Usage
1818

1919
```sh
20-
pingrb config <your-token>
20+
pingrb configure <your-token>
2121
pingrb "deploy failed"
2222
pingrb "job done" --body "backfill finished" --url https://example.com/jobs/42
2323
some-long-job && pingrb "$?" --body "done"
2424
```
2525

26-
Get the token from your Custom source on https://pingrb.com (it's the last
27-
segment of the webhook URL).
26+
Get the token by adding a CLI source on https://pingrb.com.
2827

2928
Config is stored at the platform's standard user config dir
3029
(`~/.config/pingrb` on Linux, `~/Library/Application Support/pingrb` on macOS).

‎main.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ func readConfig() (string, error) {
112112
data, err := os.ReadFile(path)
113113
if err != nil {
114114
if errors.Is(err, os.ErrNotExist) {
115-
return "", errors.New("not configured. Run `pingrb config <token>`.")
115+
return "", errors.New("not configured. Run `pingrb configure <token>`.")
116116
}
117117
return "", err
118118
}
119119
token := strings.TrimSpace(string(data))
120120
if token == "" {
121-
return "", errors.New("config is empty. Run `pingrb config <token>`.")
121+
return "", errors.New("config is empty. Run `pingrb configure <token>`.")
122122
}
123123
if strings.ContainsAny(token, "/ \t") {
124-
return "", errors.New("config looks like a URL (pre-0.2.0 format). Re-run `pingrb config <token>` with just the token.")
124+
return "", errors.New("config looks like a URL (pre-0.2.0 format). Re-run `pingrb configure <token>` with just the token.")
125125
}
126126
return token, nil
127127
}
@@ -132,7 +132,7 @@ func writeConfig(input string) error {
132132
return errors.New("token cannot be empty")
133133
}
134134
if strings.ContainsAny(token, "/ \t") {
135-
return errors.New("expected a token, not a URL or path. Copy the 32-character token from your Custom source on pingrb.com.")
135+
return errors.New("expected a token, not a URL or path. Copy the token from your CLI source on pingrb.com.")
136136
}
137137

138138
path, err := configPath()
@@ -163,7 +163,7 @@ func sendPing(token, title, body, url string) error {
163163
if err != nil {
164164
return err
165165
}
166-
endpoint := host() + "/webhooks/custom/" + token
166+
endpoint := host() + "/webhooks/cli/" + token
167167
resp, err := http.Post(endpoint, "application/json", bytes.NewReader(data))
168168
if err != nil {
169169
return err

‎main_test.go‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,35 @@ func isolateConfig(t *testing.T) {
2121

2222
const testToken = "abc123testtoken"
2323

24-
func TestConfigRoundTrip(t *testing.T) {
24+
func TestConfigureRoundTrip(t *testing.T) {
2525
isolateConfig(t)
2626

27-
if err := run([]string{"config", testToken}, io.Discard); err != nil {
27+
if err := run([]string{"configure", testToken}, io.Discard); err != nil {
2828
t.Fatal(err)
2929
}
3030

3131
var out bytes.Buffer
32-
if err := run([]string{"config"}, &out); err != nil {
32+
if err := run([]string{"configure"}, &out); err != nil {
3333
t.Fatal(err)
3434
}
3535
if got := strings.TrimSpace(out.String()); got != testToken {
3636
t.Errorf("got %q", got)
3737
}
3838
}
3939

40-
func TestConfigRejectsURL(t *testing.T) {
40+
func TestConfigureRejectsURL(t *testing.T) {
4141
isolateConfig(t)
4242

43-
err := run([]string{"config", "https://pingrb.com/webhooks/custom/abc123"}, io.Discard)
43+
err := run([]string{"configure", "https://pingrb.com/webhooks/custom/abc123"}, io.Discard)
4444
if err == nil || !strings.Contains(err.Error(), "expected a token") {
4545
t.Errorf("got %v", err)
4646
}
4747
}
4848

49-
func TestConfigRejectsEmpty(t *testing.T) {
49+
func TestConfigureRejectsEmpty(t *testing.T) {
5050
isolateConfig(t)
5151

52-
err := run([]string{"config", " "}, io.Discard)
52+
err := run([]string{"configure", " "}, io.Discard)
5353
if err == nil || !strings.Contains(err.Error(), "empty") {
5454
t.Errorf("got %v", err)
5555
}
@@ -102,7 +102,7 @@ func TestPingPostsJSON(t *testing.T) {
102102
defer srv.Close()
103103
t.Setenv("PINGRB_HOST", srv.URL)
104104

105-
if err := run([]string{"config", testToken}, io.Discard); err != nil {
105+
if err := run([]string{"configure", testToken}, io.Discard); err != nil {
106106
t.Fatal(err)
107107
}
108108
if err := run([]string{"job done", "--body", "backfill finished", "--url", "https://example.com/jobs/42"}, io.Discard); err != nil {
@@ -111,7 +111,7 @@ func TestPingPostsJSON(t *testing.T) {
111111
if got.Title != "job done" || got.Body != "backfill finished" || got.URL != "https://example.com/jobs/42" {
112112
t.Errorf("got %+v", got)
113113
}
114-
if want := "/webhooks/custom/" + testToken; gotPath != want {
114+
if want := "/webhooks/cli/" + testToken; gotPath != want {
115115
t.Errorf("path = %q, want %q", gotPath, want)
116116
}
117117
}
@@ -127,7 +127,7 @@ func TestPingOmitsEmptyFields(t *testing.T) {
127127
defer srv.Close()
128128
t.Setenv("PINGRB_HOST", srv.URL)
129129

130-
if err := run([]string{"config", testToken}, io.Discard); err != nil {
130+
if err := run([]string{"configure", testToken}, io.Discard); err != nil {
131131
t.Fatal(err)
132132
}
133133
if err := run([]string{"deploy failed"}, io.Discard); err != nil {
@@ -151,7 +151,7 @@ func TestPingErrorsOnNon2xx(t *testing.T) {
151151
defer srv.Close()
152152
t.Setenv("PINGRB_HOST", srv.URL)
153153

154-
if err := run([]string{"config", testToken}, io.Discard); err != nil {
154+
if err := run([]string{"configure", testToken}, io.Discard); err != nil {
155155
t.Fatal(err)
156156
}
157157
err := run([]string{"deploy failed"}, io.Discard)

0 commit comments

Comments
 (0)