Class: TempestTime::Commands::List

Inherits:
TempestTime::Command show all
Includes:
Helpers::TimeHelper
Defined in:
lib/tempest_time/commands/list.rb

Instance Method Summary collapse

Methods included from Helpers::TimeHelper

#beginning_of_this_week, #beginning_of_week, #formatted_date, #formatted_date_range, #formatted_time, #parsed_date_input, #parsed_time, #this_week

Methods inherited from TempestTime::Command

#command, #pastel, #prompt, #spinner, #table, #with_spinner, #with_success_fail_spinner

Constructor Details

#initialize(date, options) ⇒ List

Returns a new instance of List.



12
13
14
15
# File 'lib/tempest_time/commands/list.rb', line 12

def initialize(date, options)
  @date = date
  @options = options
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tempest_time/commands/list.rb', line 17

def execute(input: $stdin, output: $stdout)
  dates = parsed_date_input(@date)
  dates.each do |start_date|
    request = TempoAPI::Requests::ListWorklogs.new(
      start_date,
      @options['end_date'],
      @options[:user]
    )
    request.send_request
    puts "\nHere are your logs for #{formatted_date_range(start_date, @options['end_date'])}:\n"
    puts request.response_message
  end
end