Skip to content

Commit fb78bf3

Browse files
committed
feat: enhance config show command to display all accounts and improve output messaging
1 parent 85e4948 commit fb78bf3

1 file changed

Lines changed: 31 additions & 8 deletions

File tree

internal/cli/config_show.go

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ var configCmd = &cobra.Command{
2121

2222
var configShowCmd = &cobra.Command{
2323
Use: "show",
24-
Short: "Show configuration for an account",
25-
Long: `Display resolved configuration including account, key, and vendor information.`,
24+
Short: "Show configuration for an account or all accounts",
25+
Long: `Display resolved configuration including account, key, and vendor information. If no account is specified, shows all accounts.`,
2626
RunE: configShow,
2727
}
2828

2929
func init() {
30-
configShowCmd.Flags().StringVarP(&showAccount, "account", "a", "", "Account to show")
30+
configShowCmd.Flags().StringVarP(&showAccount, "account", "a", "", "Account to show (if not specified, shows all accounts)")
3131
configCmd.AddCommand(configShowCmd)
3232
}
3333

@@ -37,14 +37,37 @@ func configShow(cmd *cobra.Command, args []string) error {
3737
return err
3838
}
3939

40-
account := showAccount
41-
if account == "" {
42-
account, err = cfg.GetDefaultAccount()
43-
if err != nil {
44-
return err
40+
// If specific account requested, show only that account
41+
if showAccount != "" {
42+
return showSingleAccount(cfg, showAccount)
43+
}
44+
45+
// Show all accounts
46+
if len(cfg.Accounts) == 0 {
47+
fmt.Println("No accounts configured.")
48+
return nil
49+
}
50+
51+
fmt.Printf("Configuration Summary:\n")
52+
fmt.Printf(" Total accounts: %d\n", len(cfg.Accounts))
53+
fmt.Printf(" Total vendors: %d\n", len(cfg.Vendors))
54+
fmt.Printf(" Total keys: %d\n", len(cfg.Keys))
55+
if cfg.Settings.DefaultAccount != "" {
56+
fmt.Printf(" Default account: %s\n", cfg.Settings.DefaultAccount)
57+
}
58+
fmt.Println()
59+
60+
for accountName := range cfg.Accounts {
61+
if err := showSingleAccount(cfg, accountName); err != nil {
62+
fmt.Printf(" Error: %v\n", err)
4563
}
64+
fmt.Println("---")
4665
}
4766

67+
return nil
68+
}
69+
70+
func showSingleAccount(cfg *config.Config, account string) error {
4871
acc, ok := cfg.Accounts[account]
4972
if !ok {
5073
return errors.Wrap(errors.ErrAccountNotFound, account)

0 commit comments

Comments
 (0)