Class: Toolshed::Commands::RenameBranch

Inherits:
Base
  • Object
show all
Defined in:
lib/toolshed/commands/rename_branch.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, parse, #read_user_input, #read_user_input_body, #read_user_input_password, #read_user_input_title, #use_project_id, #use_ticket_tracker_by_type, #use_ticket_tracker_project_id, #use_ticket_tracker_project_name

Constructor Details

This class inherits a constructor from Toolshed::Commands::Base

Class Method Details

.cli_optionsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/toolshed/commands/rename_branch.rb', line 5

def self.cli_options
  {
    banner: 'Usage: rename_branch [options]',
    options: {
      branch_name: {
        short_on: '-b'
      },
      new_branch_name: {
        short_on: '-n'
      }
    }
  }
end

Instance Method Details

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



19
20
21
22
23
24
25
26
27
28
# File 'lib/toolshed/commands/rename_branch.rb', line 19

def execute(args, options = {})
  Toolshed.logger.info "Running toolshed rename_branch with #{options.inspect}"

  options[:branch_name] = options[:branch_name] || read_user_input('Branch name?', required: true)
  new_branch_name = options[:new_branch_name] || read_user_input('New Branch name?', required: true)

  branch = Toolshed::Git::Branch.new(options)
  branch.rename(new_branch_name)
  Toolshed.die
end