Class: Speedflow::Plugin::Git::Prompt
- Inherits:
-
Object
- Object
- Speedflow::Plugin::Git::Prompt
- Defined in:
- lib/speedflow/plugin/git/prompt.rb
Overview
Plugin prompt
Instance Attribute Summary collapse
-
#prompt ⇒ Object
Public: TTY prompt.
Instance Method Summary collapse
-
#ask_branch ⇒ Object
Public: Prompt ask branch.
-
#branch(branches) ⇒ Object
Public: Prompt branch.
-
#branch_type ⇒ Object
Public: Prompt branch type.
-
#errors(exception) ⇒ Object
Public: Errors from Git exception.
-
#method_missing(method, *args, &block) ⇒ Object
Delegate.
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
#prompt ⇒ Object
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_branch ⇒ Object
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 || .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 .choice branch.name, branch_full end end end |
#branch_type ⇒ Object
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 || .choice 'Local branches', :local .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. end |