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
# File 'lib/toolshed/cli.rb', line 22

def commands
  {
    'create_github_pull_request'            => Toolshed::Commands::CreateGithubPullRequest,
    'create_pivotal_tracker_note'           => Toolshed::Commands::CreatePivotalTrackerNote,
    'get_pivotal_tracker_story_information' => Toolshed::Commands::GetPivotalTrackerStoryInformation,
    'update_pivotal_tracker_story_status'   => Toolshed::Commands::UpdatePivotalTrackerStoryStatus,
  }
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