account

package
v0.0.0-...-1fcc497 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DelCommand = cli.Command{
	Name:      "delete",
	Aliases:   []string{"del"},
	Usage:     "Delete the gains Database",
	ArgsUsage: "blah",

	Flags: []cli.Flag{
		config.ConfigFileFlag,
	},
	Action: func(ctx *cli.Context) error {
		cfg, err := config.LoadConfig(ctx.String("configFileFlag"))
		if err != nil {
			return err
		}
		log.Info("Deleting the Gains Database %s", cfg.GainsDatabase)

		err = os.RemoveAll(cfg.GainsDatabase)
		if err != nil {
			return err

		}
		return nil
	},
}
View Source
var DumpCommand = cli.Command{
	Name:  "dump",
	Usage: "Prints all transactions in GainsDB",
	Flags: []cli.Flag{},
	Action: func(ctx *cli.Context) error {
		cry := accounting.Accounting{Precision: 4}
		cfg, err := config.LoadConfig(ctx.String("configFileFlag"))
		if err != nil {
			return err
		}

		db, err := cgtdb.NewLDBDatabase(cfg.GainsDatabase)
		if err != nil {
			log.Fatal(err)
		}
		defer db.Close()

		m := *model.NewModel(db, nil, cfg)

		for _, i := range m.Txns {
			fmt.Printf("[%s - %s] Traded %s x %s to receive %s x %s\n", i.Date.Format("02 Jan 2006"), i.Exchange, cry.FormatMoney(i.BaseSpent), i.BaseCurrency, cry.FormatMoney(i.QuoteReceived), i.QuoteCurrency)
		}

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL