Sha256: 783a24ebde2fcea7cd709a37a48749217908f29c8c8aaef5efe7674f390ad2e7

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'thor'

module TaskManager
  class Cli < Thor
    include Thor::Actions

    desc 'add', 'Add a new task to the waiting queue'
    method_option :name, aliases: '-n', desc: 'Name of the task', type: :string, required: true
    method_option :score, aliases: '-s', desc: 'Score of the task', type: :numeric
    def add
      TaskManager.add(options[:name], options[:score])
    end

    desc 'pick', 'Pick a task from the waiting queue'
    method_option :id, aliases: '-i', desc: 'ID of the task', type: :numeric, required: true
    def pick
      TaskManager.pick(options[:id])
    end

    desc 'delete', 'Delete a task from the waiting queue'
    method_option :id, aliases: '-i', desc: 'ID of the task', type: :numeric, required: true
    def delete
      TaskManager.delete(options[:id])
    end

    desc 'current', 'Current task'
    def current
      TaskManager.current
    end

    desc 'finish', 'Finish the current task or finish the task with ID in the waiting queue'
    method_option :id, aliases: '-i', desc: 'ID of the task', type: :numeric
    def finish
      if options[:id]
        TaskManager.finish_with_id(options[:id])
      else
        TaskManager.finish
      end
    end

    desc 'stats', 'Statistics of all queues'
    def stats
      TaskManager.stats
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
task_manager2-0.0.15 lib/task_manager/cli.rb