Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ fuzz: mod-tidy generate
cover: mod-tidy generate
go test -v -count=1 -covermode=atomic -coverprofile=cover.out -coverpkg=./... ./...
go tool cover -html=cover.out

.PHONY: docs
docs:
go run golang.org/x/pkgsite/cmd/pkgsite@latest -http=:8080
9 changes: 9 additions & 0 deletions cmd/go-cli-github/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
package main

import (
"context"
"os"
"os/signal"
"syscall"

"github.com/alecthomas/kong"
)

Expand All @@ -12,10 +17,14 @@ type CLI struct {
}

func main() {
ctx, stop := signal.NotifyContext(
context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
// parse CLI config
cli := CLI{}
kctx := kong.Parse(&cli,
kong.UsageOnError(),
kong.BindFor(ctx),
)
// execute CLI
kctx.FatalIfErrorf(kctx.Run())
Expand Down
3 changes: 2 additions & 1 deletion cmd/go-cli-github/serve.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"
"time"

Expand All @@ -11,7 +12,7 @@ import (
type ServeCmd struct{}

// Run the serve command.
func (*ServeCmd) Run() error {
func (*ServeCmd) Run(ctx context.Context) error {
fmt.Println(server.New(time.Now).Serve())
return nil
}
3 changes: 2 additions & 1 deletion cmd/go-cli-github/version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"encoding/json"
"fmt"
"runtime"
Expand All @@ -18,7 +19,7 @@ var (
type VersionCmd struct{}

// Run the Version command.
func (*VersionCmd) Run() error {
func (*VersionCmd) Run(ctx context.Context) error {
v, err := json.Marshal(
struct {
ProjectName string
Expand Down
Loading