Class: SplttyCLI::Commands::Methods
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- SplttyCLI::Commands::Methods
- Defined in:
- lib/spltty_cli/commands/methods.rb
Overview
spltty methods — list configured payment methods and their defaults.
Instance Method Summary collapse
Instance Method Details
#call(**opts) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/spltty_cli/commands/methods.rb', line 11 def call(**opts) config = SplttyCLI.load_config(opts) methods = config.payment_methods if methods.empty? puts "No payment methods configured in #{config.path}" return end width = methods.keys.map(&:length).max slug_width = methods.values.map { |c| (c["slug"] || "").length }.max puts "Payment methods (from #{config.path}):" methods.each do |name, cfg| puts format(" %-#{width}s [%-#{slug_width}s] paid_by=%-7s responsible=%-16s bill_day=%s", name, cfg["slug"], cfg["paid_by"], cfg["responsible"], cfg["bill_day"]) end rescue Config::Error => e warn "spltty methods: #{e.}" exit 1 end |