Class: Codepulse::CLI
- Inherits:
-
Object
- Object
- Codepulse::CLI
- Includes:
- TimeHelpers
- Defined in:
- lib/codepulse/cli.rb
Constant Summary collapse
- DEFAULT_STATE =
"all"- DEFAULT_BUSINESS_DAYS =
7- PRS_PER_BUSINESS_DAY =
5- MAX_BUSINESS_DAYS_LIMIT =
500- MAX_DATE_RANGE_LIMIT =
1000
Constants included from TimeHelpers
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argument_list) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Methods included from TimeHelpers
#build_us_holidays, #business_day?, #business_days_cutoff, #business_seconds_between, #date_key, #end_of_day, #last_weekday, #nth_weekday, #parse_time, #start_of_day, #us_holiday?, #us_holidays, #weekday?
Constructor Details
#initialize(argument_list) ⇒ CLI
Returns a new instance of CLI.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/codepulse/cli.rb', line 22 def initialize(argument_list) @argument_list = argument_list = { state: DEFAULT_STATE, limit: nil, gh_command: GhCliClient::DEFAULT_COMMAND, business_days_back: DEFAULT_BUSINESS_DAYS, details: false, date_range: nil } end |
Class Method Details
.start(argument_list = ARGV) ⇒ Object
18 19 20 |
# File 'lib/codepulse/cli.rb', line 18 def self.start(argument_list = ARGV) new(argument_list).run end |
Instance Method Details
#run ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/codepulse/cli.rb', line 34 def run repo = .fetch(:repo) client = GhCliClient.new(command: .fetch(:gh_command)) if [:date_range] run_date_range_mode(client, repo) else run_business_days_mode(client, repo) end rescue OptionParser::ParseError => error $stderr.puts "Error: #{error.message}" $stderr.puts $stderr.puts option_parser exit 1 rescue ConfigurationError => error $stderr.puts "Configuration error: #{error.message}" exit 1 rescue ApiError => error $stderr.puts "GitHub API error: #{error.message}" exit 1 end |