diff --git a/cmd/lotw-qsl/main.go b/cmd/lotw-qsl/main.go index 1f04d67..6c45b10 100644 --- a/cmd/lotw-qsl/main.go +++ b/cmd/lotw-qsl/main.go @@ -3,9 +3,10 @@ package main import ( "flag" "fmt" + "os" + "github.com/antihax/optional" "github.com/k0swe/lotw-qsl" - "os" ) func main() { diff --git a/wrapper.go b/wrapper.go index 6126669..36fc90e 100644 --- a/wrapper.go +++ b/wrapper.go @@ -8,14 +8,18 @@ import ( "context" ) -/* -Query LotW and return an ADIF string with the results. -*/ +// Query LotW and return an ADIF string with the results. func Query(user string, pw string, opts *QueryOpts) (string, error) { + return QueryContext(context.Background(), user, pw, opts) +} + +// QueryContext performs a context aware LotW query and returns an ADIF string +// with the results. +func QueryContext(ctx context.Context, user string, pw string, opts *QueryOpts) (string, error) { config := NewConfiguration() config.UserAgent = "k0swe/lotw-qsl 0.0.1" client := NewAPIClient(config) - queryResp, _, err := client.DefaultApi.Query(context.TODO(), user, pw, 1, opts) + queryResp, _, err := client.DefaultApi.Query(ctx, user, pw, 1, opts) if err != nil { return "", err }