Skip to content

Commit

Permalink
Fixed suggestions from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
apfohl committed May 23, 2024
1 parent c8050f2 commit 652d3e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions components/printer/loading.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/briandowns/spinner"
)

type Func[T any] func() (T, error)
type function[T any] func() (T, error)

var loadingSpinner *spinner.Spinner

Expand All @@ -16,7 +16,7 @@ func init() {
_ = loadingSpinner.Color("yellow")
}

func WithSpinner[T any](f Func[T]) (T, error) {
func WithSpinner[T any](f function[T]) (T, error) {
loadingSpinner.Start()

t, err := f()
Expand Down
8 changes: 4 additions & 4 deletions components/requests/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ func Init(hostUrl *url.URL, tokenValue string) {
}

func Get(path string, query *Query) (responseBody []byte, err error) {
loadingFunc := func() ([]byte, error) { return Do("GET", path, query, nil) }
loadingFunc := func() ([]byte, error) { return do("GET", path, query, nil) }

return printer.WithSpinner(loadingFunc)
}

func Post(path string, requestData *RequestData) (responseBody []byte, err error) {
loadingFunc := func() ([]byte, error) { return Do("POST", path, nil, requestData) }
loadingFunc := func() ([]byte, error) { return do("POST", path, nil, requestData) }

return printer.WithSpinner(loadingFunc)
}

func Patch(path string, requestBody *RequestData) (responseBody []byte, err error) {
loadingFunc := func() ([]byte, error) { return Do("PATCH", path, nil, requestBody) }
loadingFunc := func() ([]byte, error) { return do("PATCH", path, nil, requestBody) }

return printer.WithSpinner(loadingFunc)
}

func Do(method string, path string, query *Query, requestData *RequestData) (responseBody []byte, err error) {
func do(method string, path string, query *Query, requestData *RequestData) (responseBody []byte, err error) {
if client == nil || hostUnitialised() {
return nil, errors.Custom("Cannot execute requests without initializing request client first. Run `op login`")
}
Expand Down

0 comments on commit 652d3e7

Please sign in to comment.