Class: Sunshine::RmCommand
- Inherits:
-
ListCommand
- Object
- DefaultCommand
- ListCommand
- Sunshine::RmCommand
- Defined in:
- lib/commands/rm.rb
Overview
Unregister a sunshine app.
Usage: sunshine rm [options] app_name [more names…]
Arguments:
app_name Name of the application to remove.
Options:
-d, --delete Delete the app directory.
-f, --format FORMAT Set the output format (txt, yml, json)
-u, --user USER User to use for remote login. Use with -r.
-r, --remote svr1,svr2 Run on one or more remote servers.
-S, --sudo Run remote commands using sudo or sudo -u USER
-v, --verbose Run in verbose mode.
Instance Attribute Summary
Attributes inherited from ListCommand
Class Method Summary collapse
- .exec(names, config) ⇒ Object
-
.parse_args(argv) ⇒ Object
Parses the argv passed to the command.
Instance Method Summary collapse
-
#remove(app_names, delete_dir = false) ⇒ Object
Remove a registered app on a given deploy server.
Methods inherited from ListCommand
build_response, #details, #each_app, exec_each_server, #exist?, #initialize, json_format, load_list, #response_for_each, save_list, #status, #status_after_command, txt_format, yml_format
Methods inherited from DefaultCommand
build_response, copy_middleware, copy_rakefile, opt_parser, parse_remote_args
Constructor Details
This class inherits a constructor from Sunshine::ListCommand
Class Method Details
.exec(names, config) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/commands/rm.rb', line 31 def self.exec names, config delete_dir = config['delete_dir'] output = exec_each_server config do |shell| server_command = new(shell) results = server_command.remove(names, delete_dir) self.save_list server_command.app_list, shell results end return output end |
.parse_args(argv) ⇒ Object
Parses the argv passed to the command
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/commands/rm.rb', line 67 def self.parse_args argv parse_remote_args(argv) do |opt, | opt. = <<-EOF Usage: #{opt.program_name} rm [options] app_name [more names...] Arguments: app_name Name of the application to remove. EOF opt.on('-d', '--delete', 'Delete the app directory.') do ['delete_dir'] = true end end end |
Instance Method Details
#remove(app_names, delete_dir = false) ⇒ Object
Remove a registered app on a given deploy server
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/commands/rm.rb', line 50 def remove app_names, delete_dir=false each_app(*app_names) do |server_app| if delete_dir server_app.stop rescue nil server_app.shell.call "rm -rf #{server_app.root_path}" server_app.crontab.delete! end @app_list.delete server_app.name end end |