Sha256: 6064e13d582aac69209dee393af3cf7c30e0a0aeb74ffe4fc2c44d2ba6ddff27

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

module Toolshed
  class CommandNotFound < RuntimeError
  end

  class CLI
    def execute(command_name, args, options={})
      Toolshed::Client.load_credentials_if_necessary
      command = commands[command_name]
      if command
        begin
          command.new.execute(args, options)
        rescue Toolshed::Error => e
          puts "An error occurred: #{e.message}"
        rescue RuntimeError => e
          puts "An error occurred: #{e.message}"
        end
      else
        raise CommandNotFound, "Unknown command: #{command_name}"
      end
    end

    def commands
      {
        'create_pull_request'                   => Toolshed::Commands::CreatePullRequest,
        'create_pivotal_tracker_note'           => Toolshed::Commands::CreatePivotalTrackerNote,
        'ticket_information'                    => Toolshed::Commands::TicketInformation,
        'update_pivotal_tracker_story_status'   => Toolshed::Commands::UpdatePivotalTrackerStoryStatus,
        'create_branch'                         => Toolshed::Commands::CreateBranch,
        'checkout_branch'                       => Toolshed::Commands::CheckoutBranch,
        'push_branch'                           => Toolshed::Commands::PushBranch,
        'get_daily_time_update'                 => Toolshed::Commands::GetDailyTimeUpdate,
        'list_branches'                         => Toolshed::Commands::ListBranches,
        'delete_branch'                         => Toolshed::Commands::DeleteBranch,
      }
    end
  end
end

require 'toolshed/commands/create_pull_request'
require 'toolshed/commands/create_pivotal_tracker_note'
require 'toolshed/commands/ticket_information'
require 'toolshed/commands/update_pivotal_tracker_story_status'
require 'toolshed/commands/create_branch'
require 'toolshed/commands/checkout_branch'
require 'toolshed/commands/push_branch'
require 'toolshed/commands/get_daily_time_update'
require 'toolshed/commands/get_daily_time_update'
require 'toolshed/commands/list_branches'
require 'toolshed/commands/delete_branch'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
toolshed-0.0.9 lib/toolshed/cli.rb