Module: Gity::Operation
- Included in:
- Landing
- Defined in:
- lib/gity/operation.rb,
lib/gity/operation/add.rb,
lib/gity/operation/diff.rb,
lib/gity/operation/commit.rb,
lib/gity/operation/delete.rb,
lib/gity/operation/ignore.rb,
lib/gity/operation/commit_all.rb,
lib/gity/operation/remove_staged.rb
Defined Under Namespace
Modules: Add, Commit, CommitAll, Delete, Diff, Ignore, RemoveStaged
Instance Method Summary collapse
Methods included from Delete
Methods included from Common
#_cls, #_flash, #_fmt, #_logger, #_operation_done, #_pastel, #_prmt, #print_header
Methods included from Diff
Methods included from RemoveStaged
Methods included from Ignore
Methods included from Add
Methods included from Commit
Methods included from Status
Methods included from CommitAll
Instance Method Details
#prompt_operation(ws, files, opts = {}, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/gity/operation.rb', line 23 def prompt_operation(ws, files, opts = {}, &block) opts = {} if opts.nil? defOps = [:commit_all, :commit, :add, :ignore, :remove_staged, :diff, :delete] selOpts = {} defOps.each do |o| case o when :commit_all selOpts["Commit all modified and deleted files"] = o if files.has_staged? or files.has_modified? or files.has_deleted? when :commit selOpts["Add and commit"] = o if files.has_staged? or files.has_new? or files.has_modified? when :add selOpts["Add"] = o if files.has_new? when :ignore selOpts["Ignore"] = o if files.has_new? when :remove_staged selOpts["Remove Staged"] = o if files.has_staged? when :diff selOpts["Diff"] = o if files.has_modified? when :delete selOpts["Delete"] = o if files.has_staged? or files.has_modified? or files.has_deleted? end end selOpts["Done"] = :done selOpts["Quit"] = :quit begin sel = _prmt.select(_fmt("Please select one of the operations : ", :magenta), filter: true) do |m| selOpts.each do |k,v| m.choice k, v end end case sel when :commit_all _cls _prmt.puts commit_all(ws, files, &block) when :commit _cls _prmt.puts commit(ws, files, &block) when :add _cls _prmt.puts add(ws, files, &block) when :ignore _cls _prmt.puts ignore(ws, files, &block) when :remove_staged _cls _prmt.puts remove_staged(ws, files, &block) when :diff _cls _prmt.puts diff(ws, files) when :delete _cls _prmt.puts delete(ws, files, &block) when :done _operation_done(true) when :quit block.call(:before_quit) if block _operation_done(opts[:no_exit]) # no_exit will reach here block.call(:after_quit) if block end rescue TTY::Reader::InputInterrupt _prmt.puts _prmt.puts _prmt.puts _fmt "Operation aborted", :bright_yellow _prmt.puts _operation_done(opts[:no_exit]) end end |