Module: DevContext::Commands::Stashes
- Included in:
- DevContext::CLI
- Defined in:
- lib/dev_context/commands/stashes.rb
Instance Method Summary collapse
Instance Method Details
#cmd_stash ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dev_context/commands/stashes.rb', line 6 def cmd_stash args = argv.dup show_list = false all = false parser = OptionParser.new parser.on("-l", "--list", "Show stash entry titles per repo") { show_list = true } parser.on("-a", "--all", "Show stashes across all known repos") { all = true } parser.parse!(args) pattern = args.shift return usage_error("dx stash [--list] [--all|-a] [PATTERN]") unless args.empty? rows = if all known_repo_stash_rows(pattern: pattern) else active_top_stash_rows(pattern: pattern) end if rows.empty? out.puts("No repos with stashes") return 0 end render_stash_table(rows) return 0 unless show_list out.puts rows.each do |row| out.puts("#{display_path(row[:path])}:") row[:entries].each { |entry| out.puts(" - #{entry}") } end 0 rescue OptionParser::InvalidOption => e err.puts("dx: #{e.}") usage_error("dx stash [--list] [--all|-a] [PATTERN]") end |
#cmd_stashes ⇒ Object
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 |
# File 'lib/dev_context/commands/stashes.rb', line 41 def cmd_stashes args = argv.dup show_list = false parser = OptionParser.new parser.on("-l", "--list", "Show stash entry titles per repo") { show_list = true } parser.parse!(args) pattern = args.shift return usage_error("dx stashes [--list] [PATTERN]") unless args.empty? rows = known_repo_stash_rows(pattern: pattern) if rows.empty? out.puts("No repos with stashes") return 0 end render_stash_table(rows) return 0 unless show_list out.puts rows.each do |row| out.puts("#{display_path(row[:path])}:") row[:entries].each { |entry| out.puts(" - #{entry}") } end 0 rescue OptionParser::InvalidOption => e err.puts("dx: #{e.}") usage_error("dx stashes [--list] [PATTERN]") end |