Class: ClearCommand

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

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, #execute, inherited, #initialize, load, #name

Methods included from Styles

#create_style, #end_style, #styled_text

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#descriptionObject



3
4
5
# File 'lib/replicant/commands/clear_command.rb', line 3

def description
  "clear application data"
end

#runObject



16
17
18
19
20
21
22
# File 'lib/replicant/commands/clear_command.rb', line 16

def run
  package = args.present? ? args : @repl.default_package
  # Clear app data - cache, SharedPreferences, Databases
  AdbCommand.new(@repl, "shell su -c \"rm -r /data/data/#{package}/*\"").execute
  # Force application stop to recreate shared preferences, databases with new launch
  AdbCommand.new(@repl, "shell am force-stop #{package}").execute
end

#usageObject



12
13
14
# File 'lib/replicant/commands/clear_command.rb', line 12

def usage
  "#{name} [com.example.package|<empty>(when default package is set)]"
end

#valid_args?Boolean

TODO: this is not a very good argument validator

Returns:

  • (Boolean)


8
9
10
# File 'lib/replicant/commands/clear_command.rb', line 8

def valid_args?
  args.present? || @repl.default_package
end