Class: AcquiaToolbelt::CLI::Tasks
- Defined in:
- lib/acquia_toolbelt/cli/task.rb
Constant Summary
Constants inherited from Thor
Thor::AmbiguousTaskError, Thor::DynamicTask, Thor::HELP_MAPPINGS, Thor::HiddenTask, Thor::THOR_RESERVED_WORDS, Thor::UndefinedTaskError, Thor::VERSION
Instance Attribute Summary
Attributes included from Thor::Base
#args, #options, #parent_options
Instance Method Summary collapse
Methods inherited from Thor
check_unknown_options!, check_unknown_options?, command_help, default_command, desc, #help, help, long_desc, map, method_option, method_options, package_name, printable_commands, register, stop_on_unknown_option!, stop_on_unknown_option?, subcommand, subcommands
Methods included from Thor::Base
included, #initialize, register_klass_file, shell, shell=, subclass_files, subclasses
Instance Method Details
#list ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/acquia_toolbelt/cli/task.rb', line 36 def list if [:subscription] subscription = [:subscription] else subscription = AcquiaToolbelt::CLI::API.default_subscription end queue = [:queue] count = [:count] all_tasks = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/tasks" tasks = [] # Fetch a single queue from the tasks list if the queue parameter is set # otherwise just add all the tasks. if queue all_tasks.each do |task| if task['queue'] == queue tasks << task end end else all_tasks.each do |task| tasks << task end end # If there is a count to return, restrict it to that required amount. tasks = tasks.last(count.to_i) if count && tasks.any? tasks.each do |task| output_task_item(task) end end |