Class: RepoTender::CLI::Daemon::Stop

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



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/repo_tender/cli/daemon.rb', line 209

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)

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