Class: SplttyCLI::Commands::Sync
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- SplttyCLI::Commands::Sync
- Defined in:
- lib/spltty_cli/commands/sync.rb
Overview
spltty sync — reconcile ledger config between the *.notes.md frontmatter
headers and config.json. Runs structural discovery, then the two-way
notes<->config sync (see NotesSync), and reports what moved in each direction.
Instance Method Summary collapse
Instance Method Details
#call(**opts) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/spltty_cli/commands/sync.rb', line 14 def call(**opts) config = SplttyCLI.load_config(opts) Discovery.sync(config) result = NotesSync.run(config) config.save if result[:to_config].empty? && result[:to_notes].empty? && result[:globalized].empty? puts "Already in sync (accounts dir: #{config.accounts_dir})" return end puts "Synced (accounts dir: #{config.accounts_dir}):" unless result[:to_config].empty? puts " notes -> config: #{result[:to_config].join(', ')}" end unless result[:to_notes].empty? puts " config -> notes: #{result[:to_notes].join(', ')}" end unless result[:globalized].empty? puts " promoted to global groups: #{result[:globalized].join(', ')}" end rescue Config::Error => e warn "spltty sync: #{e.}" exit 1 end |