Class: Space::Src::CLI::Daemon::Install
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Space::Src::CLI::Daemon::Install
- Includes:
- Helpers, GlobalOptions
- Defined in:
- lib/space_src/cli/daemon.rb
Instance Method Summary collapse
Methods included from GlobalOptions
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
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/space_src/cli/daemon.rb', line 102 def call(plain: nil, json: nil, no_color: nil, quiet: nil, **) paths = CLI.make_paths paths.ensure! config = Config::Store.load(paths.config_file).success 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 pp = plist_path(paths, label) # Relabel: if old-identity plist exists, bootout (benign-failure-tolerant) # and remove it before bootstrapping the new-label plist. old_pp = plist_path(paths, Migration::OLD_LABEL) if File.exist?(old_pp) old_agent = make_agent(label: Migration::OLD_LABEL) old_agent.uninstall File.delete(old_pp) if File.exist?(old_pp) end resolve = Resolve.detect(repo_root: Dir.pwd) xml = build_plist(resolve: resolve, config: config, paths: paths, label: label) FileUtils.mkdir_p(File.dirname(pp)) File.write(pp, xml) agent = make_agent result = agent.install(pp) if result.failure? return fail_with(self, "bootstrap failed: #{format_failure(result.failure)}") end out.puts pastel.green("installed: #{pp}") CLI.record_outcome(Outcome.new(exit_code: 0)) end |