Class: Cardio::Commands::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/cardio/commands/command.rb

Overview

shared handling of commands splitting cardio and original args with “–”

Direct Known Subclasses

RakeCommand, RspecCommand

Instance Method Summary collapse

Instance Method Details

#exit_with_child_status(command) ⇒ Object



10
11
12
13
# File 'lib/cardio/commands/command.rb', line 10

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

#runObject



5
6
7
8
# File 'lib/cardio/commands/command.rb', line 5

def run
  puts command
  exit_with_child_status command
end

#split_args(args) ⇒ Object

split special cardio args and original command args separated by ‘–’



16
17
18
19
20
21
22
23
24
# File 'lib/cardio/commands/command.rb', line 16

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