Class: SplttyCLI::Commands::List
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- SplttyCLI::Commands::List
- Defined in:
- lib/spltty_cli/commands/list.rb
Overview
spltty list — run discovery and list the known ledgers.
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 |
# File 'lib/spltty_cli/commands/list.rb', line 12 def call(**opts) config = SplttyCLI.load_config(opts) result = Discovery.sync(config) notes = NotesSync.run(config) config.save if result[:changed] || notes.values.any? { |v| !v.empty? } if config.ledgers.empty? puts "No ledgers found under #{config.accounts_dir}" return end width = config.ledgers.keys.map(&:length).max puts "Ledgers (accounts dir: #{config.accounts_dir}):" config.ledgers.each do |name, cfg| location = cfg["dir"] ? "#{cfg['dir']}/" : cfg["file"] flags = cfg["missing"] ? " [MISSING ON DISK]" : "" puts format(" %-#{width}s %-8s %-9s %s%s", name, cfg["type"], cfg["schema"], location, flags) end rescue Config::Error => e warn "spltty list: #{e.}" exit 1 end |