diff --git a/README.md b/README.md index 02589d1..976c6be 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,17 @@ OpenStatus CLI is a command line interface for OpenStatus. ## Installation ```bash -brew tap openstatus/cli +brew tap openstatusHQ/cli brew install openstatus ``` + + +## Development + +### Docs + +Run this command to generate the documentation: + +```bash + go run cmd/docs/docs.go + ``` diff --git a/cmd/docs/docs.go b/cmd/docs/docs.go new file mode 100644 index 0000000..e075680 --- /dev/null +++ b/cmd/docs/docs.go @@ -0,0 +1,26 @@ + +package main + +import ( + "os" + + docs "github.com/urfave/cli-docs/v3" + cmd "github.com/openstatusHQ/cli/internal/cmd" +) + +func main() { + app := cmd.NewApp() + md, err := docs.ToMarkdown(app) + if err != nil { + panic(err) + } + + fi, err := os.Create("./docs/openstatus-docs.md") + if err != nil { + panic(err) + } + defer fi.Close() + if _, err := fi.WriteString("# OpenStatus CLI\n\n" + md); err != nil { + panic(err) + } +} diff --git a/cmd/openstatus/main.go b/cmd/openstatus/main.go index dd92b64..30e0a70 100644 --- a/cmd/openstatus/main.go +++ b/cmd/openstatus/main.go @@ -2,37 +2,13 @@ package main import ( "context" - "fmt" "log" "os" - - "github.com/openstatusHQ/cli/internal/monitors" - "github.com/openstatusHQ/cli/internal/run" - "github.com/openstatusHQ/cli/internal/whoami" - "github.com/urfave/cli/v3" + cmd "github.com/openstatusHQ/cli/internal/cmd" ) func main() { - app := &cli.Command{ - Name: "openstatus", - Suggest: true, - Usage: "This is OpenStatus Command Line Interface", - UsageText: "openstatus [command] [flags]", - Description: "OpenStatus is a command line interface for managing your monitors and triggering your synthetics tests.", - Version: "v0.0.4", - Commands: []*cli.Command{ - monitors.MonitorsCmd(), - run.RunCmd(), - whoami.WhoamiCmd(), - }, - EnableShellCompletion: true, - - Action: func(ctx context.Context, cmd *cli.Command) error { - cli.ShowAppHelp(cmd) - fmt.Println("\n\nPlease report any issues at https://github.com/openstatusHQ/cli/issues/new") - return nil - }, - } + app := cmd.NewApp() if err := app.Run(context.Background(), os.Args); err != nil { log.Fatal(err) diff --git a/docs/openstatus-docs.md b/docs/openstatus-docs.md index 0d41661..fab4e05 100644 --- a/docs/openstatus-docs.md +++ b/docs/openstatus-docs.md @@ -1,4 +1,4 @@ -# CLI +# OpenStatus CLI # NAME diff --git a/go.mod b/go.mod index dfdfb91..bb1556c 100644 --- a/go.mod +++ b/go.mod @@ -12,9 +12,12 @@ require ( github.com/logrusorgru/aurora/v4 v4.0.0 github.com/olekukonko/tablewriter v1.0.7 github.com/rodaine/table v1.3.0 + github.com/urfave/cli-docs/v3 v3.0.0-alpha6 + sigs.k8s.io/yaml v1.4.0 ) require ( + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/knadh/koanf/maps v0.1.2 // indirect @@ -26,7 +29,7 @@ require ( github.com/olekukonko/errors v0.0.0-20250405072817-4e6d85265da6 // indirect github.com/olekukonko/ll v0.0.8 // indirect github.com/rivo/uniseg v0.2.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect golang.org/x/sys v0.26.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 30733a7..09ace92 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -43,6 +45,8 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rodaine/table v1.3.0 h1:4/3S3SVkHnVZX91EHFvAMV7K42AnJ0XuymRR2C5HlGE= github.com/rodaine/table v1.3.0/go.mod h1:47zRsHar4zw0jgxGxL9YtFfs7EGN6B/TaS+/Dmk4WxU= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -52,6 +56,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/urfave/cli-docs/v3 v3.0.0-alpha6 h1:w/l/N0xw1rO/aHRIGXJ0lDwwYFOzilup1qGvIytP3BI= +github.com/urfave/cli-docs/v3 v3.0.0-alpha6/go.mod h1:p7Z4lg8FSTrPB9GTaNyTrK3ygffHZcK3w0cU2VE+mzU= github.com/urfave/cli/v3 v3.0.0-alpha9.2 h1:CL8llQj3dGRLVQQzHxS+ZYRLanOuhyK1fXgLKD+qV+Y= github.com/urfave/cli/v3 v3.0.0-alpha9.2/go.mod h1:FnIeEMYu+ko8zP1F9Ypr3xkZMIDqW3DR92yUtY39q1Y= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/internal/cmd/app.go b/internal/cmd/app.go new file mode 100644 index 0000000..843f548 --- /dev/null +++ b/internal/cmd/app.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "github.com/openstatusHQ/cli/internal/monitors" + "github.com/openstatusHQ/cli/internal/run" + "github.com/openstatusHQ/cli/internal/whoami" + "github.com/urfave/cli/v3" +) + +func NewApp() *cli.Command { + app := &cli.Command{ + Name: "openstatus", + Usage: "This is OpenStatus Command Line Interface", + 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", + Version: "v0.0.4", + Commands: []*cli.Command{ + monitors.MonitorsCmd(), + run.RunCmd(), + whoami.WhoamiCmd(), + }, + } + return app +}