1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2024-11-22 03:30:04 -05:00

cmd/ofx: golint

This commit is contained in:
Aaron Lindsay 2017-04-16 20:50:06 -04:00
parent 33c7ad463c
commit 94f49640b4
11 changed files with 23 additions and 25 deletions

View File

@ -8,7 +8,7 @@ import (
"os" "os"
) )
var downloadCommand = Command{ var downloadCommand = command{
Name: "download-bank", Name: "download-bank",
Description: "Download a bank account statement to a file", Description: "Download a bank account statement to a file",
Flags: flag.NewFlagSet("download-bank", flag.ExitOnError), Flags: flag.NewFlagSet("download-bank", flag.ExitOnError),
@ -38,7 +38,7 @@ func downloadCheckFlags() bool {
} }
func download() { func download() {
client, query := NewRequest() client, query := newRequest()
acctTypeEnum, err := ofxgo.NewAcctType(acctType) acctTypeEnum, err := ofxgo.NewAcctType(acctType)
if err != nil { if err != nil {

View File

@ -7,7 +7,7 @@ import (
"os" "os"
) )
var bankTransactionsCommand = Command{ var bankTransactionsCommand = command{
Name: "transactions-bank", Name: "transactions-bank",
Description: "Print bank transactions and balance", Description: "Print bank transactions and balance",
Flags: flag.NewFlagSet("transactions-bank", flag.ExitOnError), Flags: flag.NewFlagSet("transactions-bank", flag.ExitOnError),
@ -23,7 +23,7 @@ func init() {
} }
func bankTransactions() { func bankTransactions() {
client, query := NewRequest() client, query := newRequest()
acctTypeEnum, err := ofxgo.NewAcctType(acctType) acctTypeEnum, err := ofxgo.NewAcctType(acctType)
if err != nil { if err != nil {

View File

@ -8,7 +8,7 @@ import (
"os" "os"
) )
var ccDownloadCommand = Command{ var ccDownloadCommand = command{
Name: "download-cc", Name: "download-cc",
Description: "Download a credit card account statement to a file", Description: "Download a credit card account statement to a file",
Flags: flag.NewFlagSet("download-cc", flag.ExitOnError), Flags: flag.NewFlagSet("download-cc", flag.ExitOnError),
@ -34,7 +34,7 @@ func ccDownloadCheckFlags() bool {
} }
func ccDownload() { func ccDownload() {
client, query := NewRequest() client, query := newRequest()
uid, err := ofxgo.RandomUID() uid, err := ofxgo.RandomUID()
if err != nil { if err != nil {

View File

@ -7,7 +7,7 @@ import (
"os" "os"
) )
var ccTransactionsCommand = Command{ var ccTransactionsCommand = command{
Name: "transactions-cc", Name: "transactions-cc",
Description: "Print credit card transactions and balance", Description: "Print credit card transactions and balance",
Flags: flag.NewFlagSet("transactions-cc", flag.ExitOnError), Flags: flag.NewFlagSet("transactions-cc", flag.ExitOnError),
@ -21,7 +21,7 @@ func init() {
} }
func ccTransactions() { func ccTransactions() {
client, query := NewRequest() client, query := newRequest()
uid, err := ofxgo.RandomUID() uid, err := ofxgo.RandomUID()
if err != nil { if err != nil {

View File

@ -6,7 +6,7 @@ import (
"github.com/howeyc/gopass" "github.com/howeyc/gopass"
) )
type Command struct { type command struct {
Name string Name string
Description string Description string
Flags *flag.FlagSet Flags *flag.FlagSet
@ -14,7 +14,7 @@ type Command struct {
Do func() // Run the command (only called if CheckFlags returns true) Do func() // Run the command (only called if CheckFlags returns true)
} }
func (c *Command) Usage() { func (c *command) usage() {
fmt.Printf("Usage of %s:\n", c.Name) fmt.Printf("Usage of %s:\n", c.Name)
c.Flags.PrintDefaults() c.Flags.PrintDefaults()
} }

View File

@ -8,7 +8,7 @@ import (
"time" "time"
) )
var detectSettingsCommand = Command{ var detectSettingsCommand = command{
Name: "detect-settings", Name: "detect-settings",
Description: "Attempt to guess client settings needed for a particular financial institution", Description: "Attempt to guess client settings needed for a particular financial institution",
Flags: flag.NewFlagSet("detect-settings", flag.ExitOnError), Flags: flag.NewFlagSet("detect-settings", flag.ExitOnError),
@ -104,7 +104,7 @@ func detectSettings() {
fmt.Printf("noindent: %t\n", noIndent) fmt.Printf("noindent: %t\n", noIndent)
os.Exit(0) os.Exit(0)
} else { } else {
attempts += 1 attempts++
var noIndentString string var noIndentString string
if noIndent { if noIndent {
noIndentString = " noindent" noIndentString = " noindent"

View File

@ -8,7 +8,7 @@ import (
"time" "time"
) )
var getAccountsCommand = Command{ var getAccountsCommand = command{
Name: "get-accounts", Name: "get-accounts",
Description: "List accounts at your financial institution", Description: "List accounts at your financial institution",
Flags: flag.NewFlagSet("get-accounts", flag.ExitOnError), Flags: flag.NewFlagSet("get-accounts", flag.ExitOnError),
@ -21,7 +21,7 @@ func init() {
} }
func getAccounts() { func getAccounts() {
client, query := NewRequest() client, query := newRequest()
uid, err := ofxgo.RandomUID() uid, err := ofxgo.RandomUID()
if err != nil { if err != nil {

View File

@ -8,7 +8,7 @@ import (
"os" "os"
) )
var invDownloadCommand = Command{ var invDownloadCommand = command{
Name: "download-inv", Name: "download-inv",
Description: "Download a investment account statement to a file", Description: "Download a investment account statement to a file",
Flags: flag.NewFlagSet("download-inv", flag.ExitOnError), Flags: flag.NewFlagSet("download-inv", flag.ExitOnError),
@ -37,7 +37,7 @@ func invDownloadCheckFlags() bool {
} }
func invDownload() { func invDownload() {
client, query := NewRequest() client, query := newRequest()
uid, err := ofxgo.RandomUID() uid, err := ofxgo.RandomUID()
if err != nil { if err != nil {

View File

@ -7,7 +7,7 @@ import (
"os" "os"
) )
var invTransactionsCommand = Command{ var invTransactionsCommand = command{
Name: "transactions-inv", Name: "transactions-inv",
Description: "Print investment transactions", Description: "Print investment transactions",
Flags: flag.NewFlagSet("transactions-inv", flag.ExitOnError), Flags: flag.NewFlagSet("transactions-inv", flag.ExitOnError),
@ -22,7 +22,7 @@ func init() {
} }
func invTransactions() { func invTransactions() {
client, query := NewRequest() client, query := newRequest()
uid, err := ofxgo.RandomUID() uid, err := ofxgo.RandomUID()
if err != nil { if err != nil {
@ -47,8 +47,6 @@ func invTransactions() {
response, err := client.Request(query) response, err := client.Request(query)
if err != nil { if err != nil {
fmt.Println("Error requesting account statement:", err)
os.Exit(1) os.Exit(1)
} }

View File

@ -6,7 +6,7 @@ import (
"strconv" "strconv"
) )
var commands = []Command{ var commands = []command{
getAccountsCommand, getAccountsCommand,
downloadCommand, downloadCommand,
ccDownloadCommand, ccDownloadCommand,
@ -39,17 +39,17 @@ The commands are:`)
} }
} }
func runCmd(c *Command) { func runCmd(c *command) {
err := c.Flags.Parse(os.Args[2:]) err := c.Flags.Parse(os.Args[2:])
if err != nil { if err != nil {
fmt.Printf("Error parsing flags: %s\n", err) fmt.Printf("Error parsing flags: %s\n", err)
c.Usage() c.usage()
os.Exit(1) os.Exit(1)
} }
if !c.CheckFlags() { if !c.CheckFlags() {
fmt.Println() fmt.Println()
c.Usage() c.usage()
os.Exit(1) os.Exit(1)
} }

View File

@ -4,7 +4,7 @@ import (
"github.com/aclindsa/ofxgo" "github.com/aclindsa/ofxgo"
) )
func NewRequest() (*ofxgo.Client, *ofxgo.Request) { func newRequest() (*ofxgo.Client, *ofxgo.Request) {
var client = ofxgo.Client{ var client = ofxgo.Client{
AppID: appID, AppID: appID,
AppVer: appVer, AppVer: appVer,