class SyncIssues::Command
Provides the command line interface to SyncIssues
Constants
- DOC
Public Class Methods
new()
click to toggle source
# File lib/sync_issues/command.rb, line 28 def initialize @exit_status = 0 end
Public Instance Methods
run()
click to toggle source
# File lib/sync_issues/command.rb, line 32 def run handle_args(Docopt.docopt(DOC, version: VERSION)) rescue Docopt::Exit => exc exit_with_status(exc.message, exc.class.usage != '') rescue TokenError => exc exit_with_status("#{exc.message}\nPlease see: https://github.com/bboe/sync_issues#sync_issuesyaml-configuration") rescue Error, Octokit::Unauthorized => exc exit_with_status(exc.message) end
Private Instance Methods
exit_with_status(message, condition = true)
click to toggle source
# File lib/sync_issues/command.rb, line 45 def exit_with_status(message, condition = true) puts message @exit_status == 0 && condition ? 1 : @exit_status end
handle_args(options)
click to toggle source
# File lib/sync_issues/command.rb, line 50 def handle_args(options) SyncIssues.synchronizer(options['DIRECTORY'], options['REPOSITORY'], label_yaml: read_file(options['--labels']), reset_labels: options['--reset-labels'], sync_assignees: !options['--no-assignees'], sync_labels: !options['--no-labels'], update_only: options['--update']).run @exit_status end
read_file(filename)
click to toggle source
# File lib/sync_issues/command.rb, line 60 def read_file(filename) return nil if filename.nil? File.read(filename) rescue Errno::ENOENT raise Error, "not found: #{filename}" end