Sha256: 371c62b1707177a244c49113cad0377d6451988414962b52eaabb854e3b289ee

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

require 'avm/launcher/instances/runner_helper'

module Avm
  module Tools
    class Runner
      class Launcher
        class Publish < ::Avm::Launcher::Instances::RunnerHelper
          runner_with :help do
            desc 'Publica projetos ou instâncias.'
            bool_opt '--all', 'Get all instances.'
            bool_opt '-d', '--dry-run', '"Dry run" publishing.'
            bool_opt '--new', 'Publish projects not published before.'
            bool_opt '--pending', 'Publish only pending.'
            bool_opt '--recache', 'Rewrite instances cache.'
            bool_opt '--run', 'Confirm publishing.'
            arg_opt '-s', '--stereotype', 'Publish only for stereotype <stereotype>.'
            pos_arg :instance_path, repeat: true, optional: true
          end

          def run
            ::EacLauncher::Context.current.recache = parsed.run?
            build_publish_options
            instances.each do |i|
              next unless i.options.publishable?

              i.send(instance_method)
            end
          end

          private

          def dry_run?
            parsed.dry_run?
          end

          def instance_method
            run? || dry_run? ? 'publish_run' : 'publish_check'
          end

          def build_publish_options
            ::EacLauncher::Context.current.publish_options = publish_options
          end

          def publish_options
            { new: parsed.new?, stereotype: parsed.stereotype?, confirm: run? }
          end

          def run?
            parsed.run? && !dry_run?
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
avm-tools-0.97.0 lib/avm/tools/runner/launcher/publish.rb
avm-tools-0.96.0 lib/avm/tools/runner/launcher/publish.rb