diff --git a/cmd/n26/n26.go b/cmd/n26/n26.go index bd3a70a..4cbb0fe 100644 --- a/cmd/n26/n26.go +++ b/cmd/n26/n26.go @@ -15,7 +15,7 @@ import ( ) const ( - appVersion = "1.4.2" + appVersion = "1.4.3" ) func check(e error) { @@ -314,6 +314,32 @@ func main() { return nil }, }, + { + Name: "spaces", + Usage: "your spaces", + Action: func(c *cli.Context) error { + API, err := authentication() + check(err) + prettyJSON, spaces := API.GetSpaces(c.Args().First()) + if prettyJSON != "" { + fmt.Println(prettyJSON) + } else { + data := [][]string{} + for _, space := range spaces.Spaces { + data = append(data, + []string{ + space.Name, + strconv.FormatFloat(space.Balance.AvailableBalance, 'f', -1, 64), + }, + ) + } + fmt.Printf("\nYour total balance is: %s\n", strconv.FormatFloat(spaces.TotalBalance, 'f', -1, 64)) + fmt.Printf("You still have %d available spaces to create and use\n\n", spaces.UserFeatures.AvailableSpaces) + NewTableWriter().WriteData([]string{"Name", "Balance"}, data) + } + return nil + }, + }, } sort.Sort(cli.CommandsByName(app.Commands))