Skip to content

Commit

Permalink
Merge pull request #55 from masutaka/improve-debug-mode
Browse files Browse the repository at this point in the history
Useful debug mode
  • Loading branch information
masutaka committed Apr 7, 2016
2 parents 459e252 + 51327c2 commit 797560d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Options:
# Default: 20160326
u, [--until-date=UNTIL_DATE] # Retrieves GitHub user_events until the date
# Default: 20160326
d, [--debug], [--no-debug] # Debug mode
```

You can get your GitHub Nippou on today.
Expand Down
7 changes: 6 additions & 1 deletion lib/github/nippou/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Commands < Thor
class_option :until_date, type: :string,
default: Time.now.strftime('%Y%m%d'),
aliases: :u, desc: 'Retrieves GitHub user_events until the date'
class_option :debug, type: :boolean, default: false, aliases: :d, desc: 'Debug mode'

desc 'list', "Displays today's GitHub events formatted for Nippou"
def list
Expand Down Expand Up @@ -42,7 +43,7 @@ def user_events
end

def format_line(user_event, i)
puts "#{i % thread_num} : #{user_event.html_url}" if ENV['GITHUB_NIPPOU_DEBUG']
STDERR.puts "#{i % thread_num} : #{user_event.html_url}\n" if debug
issue = issue(user_event)
line = "* [%s - %s](%s) by %s" %
[issue.title.markdown_escape, user_event.repo.name, user_event.html_url, issue.user.login]
Expand Down Expand Up @@ -128,6 +129,10 @@ def thread_num
5
end.to_i
end

def debug
@debug ||= options[:debug]
end
end
end
end

0 comments on commit 797560d

Please sign in to comment.