Sha256: 43a49b2e493043dac03db18032fd415caf8cc87e97fa3fc5b3a4d460e2a416b9

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

Cartage::CLI.extend do
  desc 'Build packages on remote servers'
  long_desc <<-'DESC'
Resolve Cartage configuration locally, then execute a build script on the
configured remote server based on the resolved configuration.
  DESC
  command 'remote' do |remote|
    remote.desc 'The name of the remote server to use'
    remote.long_desc <<-'DESC'
The name of the defined remote server in the Cartage configuration file. If the
server does not exist in the configuration, an error will be reported.
    DESC
    remote.flag %i(H host), arg_name: :HOST, default_value: :default

    remote.desc 'Check plugin configuration'
    remote.long_desc <<-'DESC'
Verifies the configuration of the cartage-remote section of the Cartage
configuration file.
    DESC
    remote.command 'check-config' do |check|
      check.hide!
      check.action do |_global, _options, _args|
        cartage.remote.check_config
      end
    end

    remote.default_desc 'Run a build script remotely'
    remote.action do |_global, options, _args|
      options[:host] = nil if options[:host] == :default
      config = cartage.config(for_plugin: :remote)
      server = options[:host] || config.host || 'default'

      unless config.dig(:hosts, server)
        message = if options[:host] || config.host
                    "Host '#{server}' does not exist."
                  else
                    'Default host does not exist.'
                  end
        fail ArgumentError, message
      end

      config.host ||= server
      cartage.remote.build
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cartage-remote-2.2 lib/cartage/commands/remote.rb
cartage-remote-2.2.beta2 lib/cartage/commands/remote.rb
cartage-remote-2.2.beta1 lib/cartage/commands/remote.rb
cartage-remote-2.1 lib/cartage/commands/remote.rb
cartage-remote-2.0 lib/cartage/commands/remote.rb
cartage-remote-2.0.rc4 lib/cartage/commands/remote.rb