diff --git a/cmd/ofx/command.go b/cmd/ofx/command.go index 503a94d..0f33b41 100644 --- a/cmd/ofx/command.go +++ b/cmd/ofx/command.go @@ -23,6 +23,7 @@ func (c *command) usage() { var serverURL, username, password, org, fid, appID, appVer, ofxVersion, clientUID string var noIndentRequests bool var carriageReturn bool +var dryrun bool func defineServerFlags(f *flag.FlagSet) { f.StringVar(&serverURL, "url", "", "Financial institution's OFX Server URL (see ofxhome.com if you don't know it)") @@ -36,6 +37,7 @@ func defineServerFlags(f *flag.FlagSet) { f.StringVar(&clientUID, "clientuid", "", "Client UID (only required by a few FIs, like Chase)") f.BoolVar(&noIndentRequests, "noindent", false, "Don't indent OFX requests") f.BoolVar(&carriageReturn, "carriagereturn", false, "Use carriage return as line separator") + f.BoolVar(&dryrun, "dryrun", false, "Don't send request - print content of request instead") } func checkServerFlags() bool { diff --git a/cmd/ofx/profiledownload.go b/cmd/ofx/profiledownload.go index b6e001b..cca6986 100644 --- a/cmd/ofx/profiledownload.go +++ b/cmd/ofx/profiledownload.go @@ -54,6 +54,11 @@ func downloadProfile() { query.Prof = append(query.Prof, &profileRequest) + if dryrun { + printRequest(client, query) + return + } + response, err := client.RequestNoParse(query) if err != nil { fmt.Println("Error requesting FI profile:", err) diff --git a/cmd/ofx/util.go b/cmd/ofx/util.go index 3df4387..abb5731 100644 --- a/cmd/ofx/util.go +++ b/cmd/ofx/util.go @@ -31,3 +31,14 @@ func newRequest() (ofxgo.Client, *ofxgo.Request) { return client, &query } + +func printRequest(c ofxgo.Client, r *ofxgo.Request) { + r.SetClientFields(c) + + b, err := r.Marshal() + if err != nil { + fmt.Println(err) + return + } + fmt.Println(b) +}