Class: Sunshine::ScriptCommand
- Inherits:
-
ListCommand
- Object
- DefaultCommand
- ListCommand
- Sunshine::ScriptCommand
- Defined in:
- lib/commands/script.rb
Overview
Runs a given script of all specified sunshine apps.
Usage: sunshine script script_name [options] app_name [more names…]
Arguments:
script_name Name of the script to run.
app_name Name of the application to run script for.
Options:
-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
Takes an array and a hash, runs the command and returns: true: success false: failed exitcode: code == 0: success code != 0: failed and optionally an accompanying message.
-
.parse_args(argv) ⇒ Object
Parses the argv passed to the command.
Instance Method Summary collapse
-
#script(name, app_names) ⇒ Object
Run specified script for apps.
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
Takes an array and a hash, runs the command and returns:
true: success
false: failed
exitcode:
code == 0: success
code != 0: failed
and optionally an accompanying message.
30 31 32 33 34 35 36 37 38 |
# File 'lib/commands/script.rb', line 30 def self.exec names, config script_name = names.delete_at(0) output = exec_each_server config do |shell| new(shell).script(script_name, names) end return output end |
.parse_args(argv) ⇒ Object
Parses the argv passed to the command
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/commands/script.rb', line 54 def self.parse_args argv parse_remote_args(argv) do |opt, | opt. = <<-EOF Usage: #{opt.program_name} script script_name [options] app_name [more names...] Arguments: script_name Name of the script to run. app_name Name of the application to run script for. EOF end end |
Instance Method Details
#script(name, app_names) ⇒ Object
Run specified script for apps.
44 45 46 47 48 |
# File 'lib/commands/script.rb', line 44 def script name, app_names each_app(*app_names) do |server_app| server_app.run_script name end end |