| 1 |
// Copyright © 2015 Michael Wagner <[email protected]> |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
package main |
| 16 |
|
| 17 |
import ( |
| 18 |
"fmt" |
| 19 |
"os" |
| 20 |
|
| 21 |
"github.com/mitch000001/go-hbci/domain" |
| 22 |
"github.com/spf13/cobra" |
| 23 |
) |
| 24 |
|
| 25 |
// accountsCmd represents the accounts command |
| 26 |
var accountsCmd = &cobra.Command{ |
| 27 |
Use: "accounts", |
| 28 |
Short: "Lists all accounts associated with the UserID", |
| 29 |
Long: `This command lists all accounts associated with the userID used to |
| 30 |
authenticate. For example: |
| 31 |
|
| 32 |
banking accounts |
| 33 |
|
| 34 |
will list all accounts for the current userID.`, |
| 35 |
Run: func(cmd *cobra.Command, args []string) { |
| 36 |
accounts, err := hbciClient.Accounts() |
| 37 |
if err != nil { |
| 38 |
fmt.Println(err) |
| 39 |
os.Exit(1) |
| 40 |
} |
| 41 |
fmt.Print(domain.AccountInfos(accounts)) |
| 42 |
}, |
| 43 |
} |
| 44 |
|
| 45 |
func init() { |
| 46 |
rootCmd.AddCommand(accountsCmd) |
| 47 |
} |