Skip to content

Commit d4f6972

Browse files
Merge pull request #7 from openstatusHQ/export-cmd
🚀 export cmd
2 parents 869f748 + 865d199 commit d4f6972

File tree

7 files changed

+246
-48
lines changed

7 files changed

+246
-48
lines changed

.goreleaser.yaml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/goreleaser/goreleaser/v2.10.2/www/docs/static/schema.json
12
# This is an example .goreleaser.yml file with some sensible defaults.
23
# Make sure to check the documentation at https://goreleaser.com
34

45
# The lines below are called `modelines`. See `:help modeline`
56
# Feel free to remove those if you don't want/need to use them.
6-
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
77
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
88

99
version: 2
@@ -55,21 +55,17 @@ changelog:
5555
- "^docs:"
5656
- "^test:"
5757

58-
brews:
58+
homebrew_casks:
5959
-
6060
name: openstatus
61-
directory: Formula
61+
binary: openstatus
6262
homepage: https://www.openstatus.dev
6363
skip_upload: auto
6464
description: "OpenStatus CLI"
65-
test: |
66-
system "#{bin}/openstatus --help"
67-
extra_install: |
68-
man1.install "openstatus-docs.1"
65+
directory: Formula
66+
manpage: openstatus-docs.1
6967
repository:
70-
# Repository owner.
71-
#
72-
# Templates: allowed.
68+
7369
owner: openstatusHQ
7470

7571
# Repository name.
@@ -80,3 +76,28 @@ brews:
8076

8177
branch: main
8278
token: "{{ .Env.TAP_GITHUB_TOKEN }}"
79+
80+
# brews:
81+
# -
82+
# name: openstatus
83+
# directory: Formula
84+
# homepage: https://www.openstatus.dev
85+
# skip_upload: auto
86+
# test: |
87+
# system "#{bin}/openstatus --help"
88+
# extra_install: |
89+
# man1.install "openstatus-docs.1"
90+
# repository:
91+
# # Repository owner.
92+
# #
93+
# # Templates: allowed.
94+
# owner: openstatusHQ
95+
96+
# # Repository name.
97+
# #
98+
# # Templates: allowed.
99+
# name: homebrew-cli
100+
101+
102+
# branch: main
103+
# token: "{{ .Env.TAP_GITHUB_TOKEN }}"

cmd/openstatus/main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"fmt"
56
"log"
67
"os"
78

@@ -14,14 +15,23 @@ import (
1415
func main() {
1516
app := &cli.Command{
1617
Name: "openstatus",
18+
Suggest: true,
1719
Usage: "This is OpenStatus Command Line Interface",
18-
Description: "OpenStatus is a command line interface for managing your monitors and triggering your synthetics tests. \n\nPlease report any issues at https://github.com/openstatusHQ/cli/issues/new",
20+
UsageText: "openstatus [command] [flags]",
21+
Description: "OpenStatus is a command line interface for managing your monitors and triggering your synthetics tests.",
1922
Version: "v0.0.4",
2023
Commands: []*cli.Command{
2124
monitors.MonitorsCmd(),
2225
run.RunCmd(),
2326
whoami.WhoamiCmd(),
2427
},
28+
EnableShellCompletion: true,
29+
30+
Action: func(ctx context.Context, cmd *cli.Command) error {
31+
cli.ShowAppHelp(cmd)
32+
fmt.Println("\n\nPlease report any issues at https://github.com/openstatusHQ/cli/issues/new")
33+
return nil
34+
},
2535
}
2636

2737
if err := app.Run(context.Background(), os.Args); err != nil {

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ require (
1515
)
1616

1717
require (
18-
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
1918
github.com/fsnotify/fsnotify v1.7.0 // indirect
2019
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
2120
github.com/knadh/koanf/maps v0.1.2 // indirect
@@ -27,8 +26,7 @@ require (
2726
github.com/olekukonko/errors v0.0.0-20250405072817-4e6d85265da6 // indirect
2827
github.com/olekukonko/ll v0.0.8 // indirect
2928
github.com/rivo/uniseg v0.2.0 // indirect
30-
github.com/russross/blackfriday/v2 v2.1.0 // indirect
31-
github.com/urfave/cli-docs/v3 v3.0.0-alpha6 // indirect
3229
golang.org/x/sys v0.26.0 // indirect
3330
gopkg.in/yaml.v3 v3.0.1 // indirect
31+
sigs.k8s.io/yaml v1.4.0 // indirect
3432
)

go.sum

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
2-
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
31
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
42
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
53
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -9,6 +7,7 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
97
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
108
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
119
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
10+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1211
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
1312
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1413
github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo=
@@ -44,8 +43,6 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
4443
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
4544
github.com/rodaine/table v1.3.0 h1:4/3S3SVkHnVZX91EHFvAMV7K42AnJ0XuymRR2C5HlGE=
4645
github.com/rodaine/table v1.3.0/go.mod h1:47zRsHar4zw0jgxGxL9YtFfs7EGN6B/TaS+/Dmk4WxU=
47-
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
48-
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
4946
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5047
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
5148
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -55,8 +52,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
5552
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
5653
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
5754
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
58-
github.com/urfave/cli-docs/v3 v3.0.0-alpha6 h1:w/l/N0xw1rO/aHRIGXJ0lDwwYFOzilup1qGvIytP3BI=
59-
github.com/urfave/cli-docs/v3 v3.0.0-alpha6/go.mod h1:p7Z4lg8FSTrPB9GTaNyTrK3ygffHZcK3w0cU2VE+mzU=
6055
github.com/urfave/cli/v3 v3.0.0-alpha9.2 h1:CL8llQj3dGRLVQQzHxS+ZYRLanOuhyK1fXgLKD+qV+Y=
6156
github.com/urfave/cli/v3 v3.0.0-alpha9.2/go.mod h1:FnIeEMYu+ko8zP1F9Ypr3xkZMIDqW3DR92yUtY39q1Y=
6257
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -68,3 +63,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
6863
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6964
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
7065
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
66+
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
67+
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=

internal/config/monitor.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
package config
22

33
type Monitor struct {
4-
// Whether the monitor is active
5-
Active bool `json:"active,omitempty"`
6-
// Assertions to run on the response
7-
Assertions []Assertion `json:"assertions,omitempty"`
8-
// Time in milliseconds to wait before marking the request as degraded
9-
DegradedAfter int64 `json:"degradedAfter,omitempty"`
10-
Description string `json:"description,omitempty"`
11-
Frequency Frequency `json:"frequency"`
12-
Kind CoordinateKind `json:"kind"`
134
// Name of the monitor
14-
Name string `json:"name"`
15-
// Whether the monitor is public
16-
Public bool `json:"public,omitempty"`
5+
Name string `json:"name" ,yaml:"name"`
6+
Description string `json:"description,omitempty" ,yaml:"description,omitempty"`
7+
Frequency Frequency `json:"frequency" ,yaml:"frequency"`
178
// Regions to run the request in
18-
Regions []Region `json:"regions"`
19-
// The HTTP Request we are sending
20-
Request Request `json:"request"`
9+
Regions []Region `json:"regions" ,yaml:"regions"`
10+
// Whether the monitor is active
11+
Active bool `json:"active"`
12+
Kind CoordinateKind `json:"kind" ,yaml:"kind"`
2113
// Number of retries to attempt
22-
Retry int64 `json:"retry,omitempty"`
14+
Retry int64 `json:"retry,omitempty" ,yaml:"retry,omitempty"`
15+
// Whether the monitor is public
16+
Public bool `json:"public,omitempty" ,yaml:"public,omitempty"`
17+
// The HTTP Request we are sending
18+
Request Request `json:"request" ,yaml:"request"`
19+
// Time in milliseconds to wait before marking the request as degraded
20+
DegradedAfter int64 `json:"degradedAfter,omitempty" ,yaml:"degradedAfter,omitempty"`
2321
// Time in milliseconds to wait before marking the request as timed out
24-
Timeout int64 `json:"timeout,omitempty"`
22+
Timeout int64 `json:"timeout,omitempty" ,yaml:"timeout,omitempty"`
23+
// Assertions to run on the response
24+
Assertions []Assertion `json:"assertions,omitempty" ,yaml:"assertions,omitempty"`
2525
}
2626

2727
type Assertion struct {
2828
// Comparison operator
29-
Compare Compare `json:"compare"`
30-
Kind AssertionKind `json:"kind"`
29+
Compare Compare `json:"compare" ,yaml:"compare"`
30+
Kind AssertionKind `json:"kind" ,yaml:"kind"`
3131
// Status code to assert
3232
//
3333
// Header value to assert
3434
//
3535
// Text body to assert
36-
Target any `json:"target"`
36+
Target any `json:"target" ,yaml:"target"`
3737
// Header key to assert
38-
Key string `json:"key,omitempty"`
38+
Key string `json:"key,omitempty" ,yaml:"key,omitempty"`
3939
}
4040

4141
// The HTTP Request we are sending
4242
type Request struct {
4343
// Body to send with the request
44-
Body string `json:"body,omitempty"`
45-
Headers map[string]string `json:"headers,omitempty"`
46-
Method Method `json:"method,omitempty"`
44+
Body string `json:"body,omitempty" ,yaml:"body,omitempty"`
45+
Headers map[string]string `json:"headers,omitempty" ,yaml:"headers,omitempty"`
46+
Method Method `json:"method,omitempty" ,yaml:"method,omitempty"`
4747
// URL to request
48-
URL string `json:"url,omitempty"`
48+
URL string `json:"url,omitempty" ,yaml:"url,omitempty"`
4949
// Host to connect to
50-
Host string `json:"host,omitempty"`
50+
Host string `json:"host,omitempty" ,yaml:"host,omitempty"`
5151
// Port to connect to
52-
Port float64 `json:"port,omitempty"`
52+
Port int64 `json:"port,omitempty" ,yaml:"port,omitempty"`
5353
}
5454

5555
// Comparison operator

0 commit comments

Comments
 (0)