Class: Toolshed::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/toolshed/cli.rb

Instance Method Summary collapse

Instance Method Details

#commandsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/toolshed/cli.rb', line 22

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,
    'create_ticket_comment'                 => Toolshed::Commands::CreateTicketComment,
    'update_ticket_status'                  => Toolshed::Commands::UpdateTicketStatus,
  }
end

#execute(command_name, args, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/toolshed/cli.rb', line 6

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