commands

package
v0.0.0-...-d62bb73 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Balance = cli.Command{
	Name:    "balance",
	Aliases: []string{"bal"},
	Usage:   "get your balance",
	Flags: []cli.Flag{
		nativeFlag,
		cli.BoolFlag{
			Name:  "id",
			Usage: "Show account id",
		},
	},
	Action: func(c *cli.Context) error {
		native := c.Bool("native")
		showID := c.Bool("id")
		accounts, err := client(c).Accounts()
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}
		for _, acc := range accounts {
			if showID {
				fmt.Printf("%s\t", acc.ID)
			}
			fmt.Printf("%s\t", acc.Name)
			printfBalance(native, acc)
			fmt.Printf("\n")
		}
		return nil
	},
}

Balance cmd

View Source
var TransactionList = cli.Command{
	Name:    "list",
	Aliases: []string{"ls"},
	Usage:   "list your last transactions",
	Flags: []cli.Flag{
		nativeFlag,
		cli.StringFlag{
			Name:  "acc, id",
			Usage: "account id (you can get it from balance)",
		},
	},
	Action: func(c *cli.Context) error {
		native := c.Bool("native")
		transactions, err := client(c).Transactions(c.String("acc"))
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}
		for _, transaction := range transactions {
			status := "?"
			if transaction.Status == "completed" {
				status = "✓"
			}
			fmt.Printf("%s\t", status)
			printfMoney(native, transaction.Amount, transaction.NativeAmount)
			fmt.Printf("%s\t", transaction.Created.Format("2006-01-02 15:04"))
			fmt.Printf("%s\n", transaction.Description)
		}
		return nil
	},
}

TransactionList cmd

View Source
var TransactionSend = cli.Command{
	Name:    "send",
	Aliases: []string{"mv"},
	Usage:   "Send money to a BTC address",
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "acc, id",
			Usage: "account id (you can get it from balance)",
		},
		cli.StringFlag{
			Name:  "to",
			Usage: "BTC address to send money to",
		},
		cli.StringFlag{
			Name:  "amount",
			Usage: "Amount of money to send",
		},
		cli.StringFlag{
			Name:  "currency",
			Usage: "Currency of money to send (e.g. BTC, USD, BRL)",
			Value: "BTC",
		},
		cli.StringFlag{
			Name:  "description",
			Usage: "Description of the transaction",
		},
	},
	Action: func(c *cli.Context) error {
		from := c.String("acc")
		to := c.String("to")
		amount := c.String("amount")
		currency := c.String("currency")
		description := c.String("description")
		fmt.Printf("Sending %s %s to %s...\n", amount, currency, to)
		fmt.Printf("Press 'Enter' to confirm or 'CTRL-C' to cancel...")
		bufio.NewReader(os.Stdin).ReadBytes('\n')
		transaction, err := client(c).Send(
			from,
			to,
			amount,
			currency,
			description,
		)
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}
		fmt.Println(transaction)
		return nil
	},
}

TransactionSend cmd

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