Sha256: 91e0f2490a3b97d2a9e95e873a60c6e8a836d7cb52b171e9e5a7f6cade0a8ca1

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

#!/usr/bin/env ruby -W
# Copyright (c) 2015 Scott Williams

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")

require "issue_exporter/cli"

module IssueExporting
  class Command
    include CLI

    def about
      VERSION
    end

    def usage
      <<HERE
Download all open issues from a GitHub repository.

Usage: #{$PROGRAM_NAME} [OPTION]... [OWNER] [REPO] [TOKEN]

Example: #{$PROGRAM_NAME} swilliams issue_exporter abcdef

-o, --output      DIRECTORY
                    set output path
                      (default: current working directory)

    --multiple-files Use a separate file for each issue
                    (default: one single file)

    --closed      include closed issues (default: false)

-h, --help        display this help and exit
    --version     display the version

HERE

    end

    def initialize
      super
      @output = nil
      @multiple_files = false
      @include_closed_issues = false
    end

    def correct_number_of_args(arg_count)
      arg_count == 3
    end

    def define_options(opts)
      opts.on("-o", "--output ARG") { |arg| @output = arg }
      opts.on("--multiple-files")   { @multiple_files = true }
      opts.on("--closed")           { @include_closed_issues = true }
    end

    def process_input(arg, index)
      case index
      when 0
        @owner = arg
      when 1
        @repo = arg
      when 2
        @token = arg
      end
    end

    def perform_action
      options = { path: @output,
                  multiple_files: @multiple_files,
                  include_closed_issues: @include_closed_issues }
      exporter = IssueExporting::Exporter.new(@owner, @repo, @token, options)
      exporter.export
    end
  end
end

IssueExporting::Command.new.run

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github_issue_exporter-0.2.1 bin/export-github-issues