Class: SplttyCLI::Commands::Groups

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/spltty_cli/commands/groups.rb

Overview

spltty groups — list global split groups and each ledger's own groups.

Instance Method Summary collapse

Instance Method Details

#call(**opts) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/spltty_cli/commands/groups.rb', line 12

def call(**opts)
  config = SplttyCLI.load_config(opts)

  printed = false
  unless config.groups.empty?
    puts "Global groups:"
    print_groups(config.groups)
    printed = true
  end

  config.ledgers.each do |name, entry|
    groups = entry["groups"]
    next unless groups.is_a?(Hash) && !groups.empty?

    puts "#{name}:"
    print_groups(groups)
    printed = true
  end

  puts "No split groups defined." unless printed
rescue Config::Error => e
  warn "spltty groups: #{e.message}"
  exit 1
end