class GitPrepareBranch::Command
Attributes
command[R]
key[R]
name[R]
options[R]
Public Class Methods
new(key, name, command, options={})
click to toggle source
# File lib/git-prepare-branch/command.rb, line 7 def initialize(key, name, command, options={}) @key = key @name = name @command = command @options = options end
Public Instance Methods
call(context)
click to toggle source
# 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
description()
click to toggle source
# File lib/git-prepare-branch/command.rb, line 21 def description options[:description] end
Private Instance Methods
capture_inputs(context)
click to toggle source
# File lib/git-prepare-branch/command.rb, line 27 def capture_inputs(context) return {} unless options[:input] options[:input].each_with_object({}) do |(key, value), object| object[key] = context.terminal.ask value[:prompt], autocomplete_strategy: [value[:autocomplete_strategy], context.variables] end end
run_as_shell_command(context, inputs)
click to toggle source
# File lib/git-prepare-branch/command.rb, line 34 def run_as_shell_command(context, inputs) context.terminal.call format( command, context.variables.to_h.merge(inputs) ) end
run_proc(context, inputs)
click to toggle source
# File lib/git-prepare-branch/command.rb, line 41 def run_proc(context, inputs) command.call(context, inputs) end