func createDefaultConfigFile(destinationPath string) error {
	dest, err := os.OpenFile(filepath.Join(destinationPath, defaultConfigFilename),
		os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
	if err != nil {
		return err
	}
	defer dest.Close()
	writer := bufio.NewWriter(dest)
	defaultArgs := []byte("dbuser=opencx\ndbpassword=testpass\n")
	_, err = writer.Write(defaultArgs)
	if err != nil {
		return err
	}
	writer.Flush()
	return nil
}
createDefaultConfigFile creates a config file  -- only call this if the
config file isn't already there
package cxdbsql
import (
	"bufio"
	"os"
	"path/filepath"
	"github.com/jessevdk/go-flags"
	"github.com/mit-dci/opencx/logging"
)
type dbsqlConfig struct {
	ConfigFile string
	DBHomeDir string `long:"dir" description:"Location of the root directory for the sql db info and config"`
	DBUsername string `long:"dbuser" description:"database username"`
	DBPassword string `long:"dbpassword" description:"database password"`
	DBHost     string `long:"dbhost" description:"Host for the database connection"`
	DBPort     uint16 `long:"dbport" description:"Port for the database connection"`
	ReadOnlyOrderSchemaName   string `long:"readonlyorderschema" description:"Name of read-only orderbook schema"`
	ReadOnlyAuctionSchemaName string `long:"readonlyauctionschema" description:"Name of read-only auction schema"`
	ReadOnlyBalanceSchemaName string `long:"readonlybalanceschema" description:"Name of read-only balance schema"`
	BalanceSchemaName         string `long:"balanceschema" description:"Name of balance schema"`
	DepositSchemaName         string `long:"depositschema" description:"Name of deposit schema"`
	PendingDepositSchemaName  string `long:"penddepschema" description:"Name of pending deposit schema"`
	PuzzleSchemaName          string `long:"puzzleschema" description:"Name of schema for puzzle orderbooks"`
	AuctionSchemaName         string `long:"auctionschema" description:"Name of schema for auction ID"`
	AuctionOrderSchemaName    string `long:"auctionorderschema" description:"Name of schema for auction orderbook"`
	OrderSchemaName           string `long:"orderschema" description:"Name of schema for limit orderbook"`
	PeerSchemaName            string `long:"peerschema" description:"Name of schema for peer storage"`
	PuzzleTableName       string `long:"puzzletable" description:"Name of table for puzzle orderbooks"`
	AuctionOrderTableName string `long:"auctionordertable" description:"Name of table for auction orders"`
	PeerTableName         string `long:"peertable" description:"Name of table for peer storage"`
}
var (
	defaultConfigFilename = "sqldb.conf"
	defaultHomeDir        = os.Getenv("HOME")
	defaultDBHomeDirName  = defaultHomeDir + "/.opencx/db/"
	defaultDBPort         = uint16(3306)
	defaultDBHost         = "localhost"
	defaultDBUser         = "opencx"
	defaultDBPass         = "testpass"
	defaultReadOnlyOrderSchema   = "orders_readonly"
	defaultReadOnlyAuctionSchema = "auctionorders_readonly"
	defaultReadOnlyBalanceSchema = "balances_readonly"
	defaultBalanceSchema         = "balances"
	defaultDepositSchema         = "deposit"
	defaultPendingDepositSchema  = "pending_deposits"
	defaultPuzzleSchema          = "puzzle"
	defaultAuctionSchema         = "auctions"
	defaultAuctionOrderSchema    = "auctionorder"
	defaultOrderSchema           = "orders"
	defaultPeerSchema            = "peers"
	defaultAuctionOrderTable = "auctionorders"
	defaultPuzzleTable       = "puzzles"
	defaultPeerTable         = "opencxpeers"
	defaultConf = &dbsqlConfig{
		DBHomeDir: defaultDBHomeDirName,
		DBUsername: defaultDBUser,
		DBPassword: defaultDBPass,
		DBHost:     defaultDBHost,
		DBPort:     defaultDBPort,
		ReadOnlyAuctionSchemaName: defaultReadOnlyAuctionSchema,
		ReadOnlyOrderSchemaName:   defaultReadOnlyOrderSchema,
		ReadOnlyBalanceSchemaName: defaultReadOnlyBalanceSchema,
		BalanceSchemaName:         defaultBalanceSchema,
		DepositSchemaName:         defaultDepositSchema,
		PendingDepositSchemaName:  defaultPendingDepositSchema,
		PuzzleSchemaName:          defaultPuzzleSchema,
		AuctionSchemaName:         defaultAuctionSchema,
		AuctionOrderSchemaName:    defaultAuctionOrderSchema,
		OrderSchemaName:           defaultOrderSchema,
		PeerSchemaName:            defaultPeerSchema,
		PuzzleTableName:       defaultPuzzleTable,
		AuctionOrderTableName: defaultAuctionOrderTable,
		PeerTableName:         defaultPeerTable,
	}
)
func newConfigParser(conf *dbsqlConfig, options flags.Options) *flags.Parser {
	parser := flags.NewParser(conf, options)
	return parser
}