mirror of
https://github.com/aclindsa/ofxgo.git
synced 2024-11-21 11:20:04 -05:00
cmd/ofx: Add -dryrun
This commit is contained in:
parent
4c7c48cab7
commit
56ca46714b
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user