Class: GitPrepareBranch::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/git-prepare-branch/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, name, command, options = {}) ⇒ Command

Returns a new instance of Command.



7
8
9
10
11
12
# File 'lib/git-prepare-branch/command.rb', line 7

def initialize(key, name, command, options={})
  @key = key
  @name = name
  @command = command
  @options = options
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/git-prepare-branch/command.rb', line 5

def command
  @command
end

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/git-prepare-branch/command.rb', line 5

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/git-prepare-branch/command.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/git-prepare-branch/command.rb', line 5

def options
  @options
end

Instance Method Details

#call(context) ⇒ Object



14
15
16
17
18
19
# File 'lib/git-prepare-branch/command.rb', line 14

def call(context)
  inputs = capture_inputs(context)
  run_proc(context, inputs) if command.is_a?(Proc)
  run_as_shell_command(context, inputs) if command.is_a?(String)
  context.terminal.prompt_to_continue if options[:prompt_to_continue]
end

#descriptionObject



21
22
23
# File 'lib/git-prepare-branch/command.rb', line 21

def description
  options[:description]
end