Class: AdbCommand

Inherits:
Command show all
Defined in:
lib/replicant/commands/adb_command.rb

Defined Under Namespace

Classes: Result

Constant Summary

Constants included from Styles

Styles::CONSOLE_WIDTH, Styles::REPL_OUT, Styles::STYLES

Instance Attribute Summary

Attributes inherited from Command

#args

Instance Method Summary collapse

Methods inherited from Command

all, #description, #execute, inherited, #initialize, load, #name, #usage

Methods included from Styles

#create_style, #end_style, #styled_text

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#commandObject



29
30
31
32
33
34
35
36
# File 'lib/replicant/commands/adb_command.rb', line 29

def command
  adb = "adb"
  adb << " -s #{@repl.default_device.id}" if @repl.default_device
  adb << " #{args}"
  adb << " #{@repl.default_package}" if @repl.default_package && package_dependent?
  adb << " 2>&1" # redirect stderr to stdout so that we can silence it
  adb
end

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/replicant/commands/adb_command.rb', line 11

def run
  Result.new.tap do |result|
    cmd = "#{command}"

    putsd cmd

    if interactive?
      system cmd
    else
      result.output = `#{cmd}`
      output result.output
    end
    result.pid  = $?.pid
    result.code = $?.exitstatus
    putsd "Command returned with exit status #{result.code}"
  end
end