Class: RepoTender::CLI::Daemon::Start

Inherits:
Dry::CLI::Command
  • Object
show all
Includes:
Helpers, GlobalOptions
Defined in:
lib/repo_tender/cli/daemon.rb

Instance Method Summary collapse

Methods included from GlobalOptions

included

Methods included from Helpers

build_plist, fail_with, format_failure, make_agent, plist_path

Instance Method Details

#call(plain: nil, json: nil, no_color: nil, quiet: nil) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/repo_tender/cli/daemon.rb', line 181

def call(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
  label = Launchd::Agent::DEFAULT_LABEL
  pp = plist_path(paths, label)

  agent = make_agent
  result = agent.start(pp)
  if result.failure?
    return fail_with(self, "start failed: #{format_failure(result.failure)}")
  end
  out.puts pastel.green("started: #{label}")
  CLI.record_outcome(Outcome.new(exit_code: 0))
end