Sha256: 3b4c6adfff519be69b21e901a1b9bae391b230f049c2a9de61bdfb6259cfe4d4

Contents?: true

Size: 992 Bytes

Versions: 5

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

module Gl
  class Issues < Thor
    desc 'list', 'list open issues'
    option :i
    def list(project = nil)
      issues = Gitlab.issues(Gl.current_project(project), state: :opened).auto_paginate

      issues_list = issues.map do |issue|
        [issue.iid, issue.author.name, issue.title]
      end

      if options[:i]
        prompt = TTY::Prompt.new(interrupt: :exit)
        choice = prompt.select('Open a issue') do |menu|
          issues_list.each do |issue|
            menu.choice issue.join(' - '), issue[0]
          end
        end
        Gl.open_in_browser("#{Gl.current_project}/issues/#{choice}")
      else
        table = TTY::Table.new(%w[IID Author Title],
                               issues_list)
        puts table.render(:ascii, padding: [0, 1])
      end
    end

    desc 'open', 'opens the issues overview in your browser'
    def open(id = nil)
      Gl.open_in_browser("#{Gl.current_project}/issues/#{id}")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gl-0.3.1 lib/gl/cli/issues.rb
gl-0.3.0 lib/gl/cli/issues.rb
gl-0.2.1 lib/gl/cli/issues.rb
gl-0.2.0 lib/gl/cli/issues.rb
gl-0.1.0 lib/gl/cli/issues.rb