Class: Space::Src::CLI::Clone

Inherits:
Dry::CLI::Command
  • Object
show all
Includes:
GlobalOptions
Defined in:
lib/space_src/cli/clone.rb

Overview

‘clone` command: APFS COW copy of an evergreen repo into a working dir. Resolves each NAME against config.base_dir and copies via cp -Rc. Multiple names are processed independently; a per-name failure is reported on err and does not abort the others. Exit code is 1 if any name failed, else 0.

Instance Method Summary collapse

Methods included from GlobalOptions

included

Instance Method Details

#call(names:, into: ".", plain: nil, json: nil, no_color: nil, quiet: nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/space_src/cli/clone.rb', line 25

def call(names:, into: ".", plain: nil, json: nil, no_color: nil, quiet: nil, **)
  mode = UI::Mode.resolve(
    flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
    env: CLI.env,
    out: out
  )
  pastel = Pastel.new(enabled: mode.color)

  paths = CLI.make_paths
  config = Config::Store.load(paths.config_file).success
  cloner = Cloner.new(base_dir: config.base_dir)

  any_failure = false
  names.each do |name|
    result = cloner.call(name: name, into: into)
    if result.success?
      dest = result.success
      out.puts pastel.green("cloned: #{name}#{dest}")
    else
      err.puts result.failure
      any_failure = true
    end
  end

  CLI.record_outcome(Outcome.new(exit_code: any_failure ? 1 : 0))
end