module GitHubPr::CLI

Public Class Methods

current_branch() click to toggle source
# File lib/github-pr/cli.rb, line 52
def self.current_branch
     `git branch | grep "^*"`.chomp[2..-1]
end
parse(argv) click to toggle source
# File lib/github-pr/cli.rb, line 5
      def self.parse(argv)
              options = {}
              OptionParser.new do |opts|
                      opts.banner = "Usage: github-pr -b master -f shop-redesign -a hovox"
                      opts.separator ""
                      opts.separator "Your current directory must be your git directory"
                      opts.separator "github-pr -b master -a hovox"
                      opts.separator "Will use current branch as feature branch"
                      opts.separator ""
                      opts.separator "github-pr -a hovox"
                      opts.separator "Will use master branch as base branch and current branch as feature branch"
                      opts.separator ""
                      opts.separator "Command should be run from project's directory"


                      opts.on("-b", "--base BASE", "Base branch") do |b|
                              options[:base] = b
                      end
                      opts.on("-f", "--feature FEATURE", "Feature branch") do |f|
                              options[:feature] = f
                      end
                      opts.on("-a", "--assign USERNAME", "GitHub user name whom to assign") do |a|
                              options[:assign] = a
                      end
                      opts.on("-t", "--title PULLREQUESTTITLE", "Title of the pull request") do |t|
                              options[:title] = t
                      end
                      opts.on("-g", "--github-token GITHUBTOKEN", "Generated user token from GitHub") do |t|
                              options[:token] = t
                      end
                      opts.on("-u", "--url GITHUBURL", "GitHub repo url, optional. We will try to get url from git.") do |t|
                              options[:url] = t
                      end
              end.parse!(argv)

              raise 'You must assign to someone' if options[:assign].nil?

              options[:base] = 'master' if options[:base].nil?
  # e.g. * master cutting '* ' from begining
  options[:feature] = self.current_branch if options[:feature].nil?
  options[:title] = options[:feature] if options[:title].nil?
              options[:token] = options[:token] if options[:token].nil?
              options[:url] = options[:url] if options[:url].nil?

  return options
end