Skip to content

Commit

Permalink
feat(cli): adding command to get spaces information
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme Thomazi Bonicontro committed Aug 29, 2018
1 parent 2f3c267 commit 117103c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion cmd/n26/n26.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

const (
appVersion = "1.4.2"
appVersion = "1.4.3"
)

func check(e error) {
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 117103c

Please sign in to comment.