Class: TempestTime::Commands::Submit

Inherits:
TempestTime::Command show all
Defined in:
lib/tempest_time/commands/submit.rb

Instance Method Summary collapse

Methods inherited from TempestTime::Command

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

Constructor Details

#initialize(options) ⇒ Submit

Returns a new instance of Submit.



9
10
11
# File 'lib/tempest_time/commands/submit.rb', line 9

def initialize(options)
  @options = options
end

Instance Method Details

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



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tempest_time/commands/submit.rb', line 13

def execute(input: $stdin, output: $stdout)
  # Command logic goes here ...
  reviewer = prompt.ask('Who should review this timesheet? (username)')
  message = "Submit this week's timesheet to " + pastel.green(reviewer) + '?'
  abort unless prompt.yes?(message)
  abort unless prompt.yes?('Are you sure? No edits can be made once submitted!')

  with_success_fail_spinner("Submitting this week's timesheet...") do
    TempoAPI::Requests::SubmitTimesheet.new(reviewer).send_request
  end
end