Class: Agentilda::CLI::Resync::Dirs

Inherits:
Base
  • Object
show all
Defined in:
lib/agentilda/cli/resync/subcommands/dirs.rb

Overview

resync dirs — reconcile folder names with folder contents.

Constant Summary

Constants included from UI

UI::MAX_WIDTH, UI::METER_WIDTH, UI::MIN_WIDTH, UI::NO_FAILURE, UI::NO_FIELDS, UI::NO_TIMEOUT, UI::PROGRESS_THRESHOLD, UI::TIMER_WARNING, UI::TIMER_WIDTH

Instance Method Summary collapse

Methods inherited from Base

inherited

Methods included from UI

abbreviate, activity_for, animate?, box, box_height, color?, concurrently, countdown, default_jobs, display_width, elapsed, #error, fit, #info, line, log, logging_activity, meter, monotonic, once, paint, #paint, pastel, popup, report_line, reset!, said, #say, solo_spinner, spinning, stepping, #success, threaded, tty?, #warn, width

Instance Method Details

#call(**options) ⇒ void

This method returns an undefined value.

Parameters:

  • options (Hash)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/agentilda/cli/resync/subcommands/dirs.rb', line 21

def call(**options)
  changes = Agentilda::Resync::Dirs.new(tree: tree_for(options))
    .call(commit: commit?(options))

  if changes.empty?
    success("Every folder is already named NNN.MM-<emoji>-<slug> and the emoji matches.") unless quiet?(options)
    return
  end

  changes.each do |change|
    puts "#{change.dirname}\t#{File.basename(change.target)}\t#{change.reason}"
    next if quiet?(options)

    say("#{paint(change.dirname, :bright_black)}#{File.basename(change.target)}")
    say("  #{paint(change.reason, :yellow)}", bullet: " ")
  end

  return if quiet?(options)

  if commit?(options)
    success("Renamed #{changes.size} folder#{"s" unless changes.size == 1}.")
  else
    dry_run_footer(changes.size, "rename#{"s" unless changes.size == 1}")
  end
end