Sha256: 36e919833f6e61db3ff0890e85afde4d3ca63f211f6d2599d1c412fb7121b05a

Contents?: true

Size: 719 Bytes

Versions: 9

Compression:

Stored size: 719 Bytes

Contents

module Cardio
  class Commands
    # shared handling of commands splitting cardio and original args with "--"
    class Command
      def run
        puts command
        exit_with_child_status command
      end

      def exit_with_child_status command
        command += " 2>&1"
        exit $CHILD_STATUS.exitstatus unless system command
      end

      # split special cardio args and original command args separated by '--'
      def split_args args
        before_split = true
        cardio_args, command_args =
          args.partition do |a|
            before_split = (a == "--" ? false : before_split)
          end
        command_args.shift
        [cardio_args, command_args]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
card-1.104.2 lib/cardio/commands/command.rb
card-1.104.1 lib/cardio/commands/command.rb
card-1.104.0 lib/cardio/commands/command.rb
card-1.103.4 lib/cardio/commands/command.rb
card-1.103.3 lib/cardio/commands/command.rb
card-1.103.2 lib/cardio/commands/command.rb
card-1.103.1 lib/cardio/commands/command.rb
card-1.103.0 lib/cardio/commands/command.rb
card-1.102.0 lib/cardio/commands/command.rb