Sha256: 962b3210304ee44af420d2e5f00a0dace1dc78ffb5beea8a13d5eba7a3deaa9c

Contents?: true

Size: 1016 Bytes

Versions: 8

Compression:

Stored size: 1016 Bytes

Contents

require 'English'

module Wordmove
  module Actions
    # Run a command on the local system.
    # Command won't be run if +--simulate+ flag is present on CLI.
    # @note This action is *not* meant to be organized, but as a standalone one.
    class RunLocalCommand
      extend LightService::Action
      include Wordmove::Actions::Helpers

      expects :command,
              :cli_options,
              :logger

      # @!method execute
      #   @param command [String] The command to run
      #   @param cli_options [Hash]
      #   @param logger [Wordmove::Logger]
      #   @return [LightService::Context] Action's context
      executed do |context|
        context.logger.task_step true, context.command

        next context if simulate?(cli_options: context.cli_options)

        begin
          system(context.command, exception: true)
        rescue RuntimeError, SystemExit => e
          context.fail!("Local command status reports an error: #{e.message}")
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wordmove-6.0.0.alpha.8 lib/wordmove/actions/run_local_command.rb
wordmove-6.0.0.alpha.7 lib/wordmove/actions/run_local_command.rb
wordmove-6.0.0.alpha.6 lib/wordmove/actions/run_local_command.rb
wordmove-6.0.0.alpha.5 lib/wordmove/actions/run_local_command.rb
wordmove-6.0.0.alpha.4 lib/wordmove/actions/run_local_command.rb
wordmove-6.0.0.alpha.3 lib/wordmove/actions/run_local_command.rb
wordmove-6.0.0.alpha.2 lib/wordmove/actions/run_local_command.rb
wordmove-6.0.0.alpha.1 lib/wordmove/actions/run_local_command.rb