Class: Speedflow::Plugin::Git::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/speedflow/plugin/git/prompt.rb

Overview

Plugin prompt

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Delegate.

method - Method. args - Arguments. block - Block.

Returns wathever.



60
61
62
# File 'lib/speedflow/plugin/git/prompt.rb', line 60

def method_missing(method, *args, &block)
  prompt.send(method, *args, &block)
end

Instance Attribute Details

#promptObject

Public: TTY prompt.

Returns ::Speedflow::Plugin::Prompt instance.



67
68
69
# File 'lib/speedflow/plugin/git/prompt.rb', line 67

def prompt
  @prompt ||= ::Speedflow::Plugin::Prompt.new
end

Instance Method Details

#ask_branchObject

Public: Prompt ask branch.

Returns String of title.



12
13
14
# File 'lib/speedflow/plugin/git/prompt.rb', line 12

def ask_branch
  ask('What is the name of branch?', required: true)
end

#branch(branches) ⇒ Object

Public: Prompt branch.

branches - List of branches.

Returns branch name.



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/speedflow/plugin/git/prompt.rb', line 21

def branch(branches)
  prompt.select('Choose the branch:', required: true) do |menu|
    menu.choice 'Re-select branch type', :retry
    branches.each do |branch|
      next if branch.name.include? '->'
      branch_full = branch.name
      branch_full = "#{branch.remote}/#{branch.name}" if branch.remote
      menu.choice branch.name, branch_full
    end
  end
end

#branch_typeObject

Public: Prompt branch type.

Returns String of type (:local or :remote).



36
37
38
39
40
41
# File 'lib/speedflow/plugin/git/prompt.rb', line 36

def branch_type
  prompt.select('Choose the branch type:', required: true) do |menu|
    menu.choice 'Local branches', :local
    menu.choice 'Remote branches', :remote
  end
end

#errors(exception) ⇒ Object

Public: Errors from Git exception.

exception - Git exception.

Returns nothing.



48
49
50
51
# File 'lib/speedflow/plugin/git/prompt.rb', line 48

def errors(exception)
  prompt.error 'Git errors'
  prompt.warn exception.message
end