Class: ClearCommand

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

Instance Attribute Summary

Attributes inherited from Command

#args

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#descriptionObject



313
314
315
# File 'lib/replicant/command.rb', line 313

def description
  "clear application data"
end

#runObject



326
327
328
329
330
331
332
# File 'lib/replicant/command.rb', line 326

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



322
323
324
# File 'lib/replicant/command.rb', line 322

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)


318
319
320
# File 'lib/replicant/command.rb', line 318

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