Class: ClearCommand
- 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
Instance Method Summary collapse
- #description ⇒ Object
- #run ⇒ Object
- #usage ⇒ Object
-
#valid_args? ⇒ Boolean
TODO: this is not a very good argument validator.
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
#description ⇒ Object
3 4 5 |
# File 'lib/replicant/commands/clear_command.rb', line 3 def description "clear application data" end |
#run ⇒ Object
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 |
#usage ⇒ Object
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
8 9 10 |
# File 'lib/replicant/commands/clear_command.rb', line 8 def valid_args? args.present? || @repl.default_package end |