Class: TempestTime::Command
Direct Known Subclasses
TempestTime::Commands::Config::App, TempestTime::Commands::Config::Auth, TempestTime::Commands::Delete, TempestTime::Commands::Issue::List, TempestTime::Commands::Issue::Open, TempestTime::Commands::List, TempestTime::Commands::Report, TempestTime::Commands::Setup, TempestTime::Commands::Submit, TempestTime::Commands::Teams::Add, TempestTime::Commands::Teams::Delete, TempestTime::Commands::Teams::Edit, TempestTime::Commands::Timer::Delete, TempestTime::Commands::Timer::List, TempestTime::Commands::Timer::Pause, TempestTime::Commands::Timer::Start, TempestTime::Commands::Timer::Status, TempestTime::Commands::Timer::Track, TempestTime::Commands::Track
Instance Method Summary
collapse
#automatic_issue
#braced, #with_percent_sign
#beginning_of_week, #dates_in_range, #end_of_week, #formatted_date, #formatted_date_range, #formatted_time, #formatted_time_for_input, #formatted_time_long, #future_dates, #parsed_time, #past_dates, #past_week_selections, #week_beginnings, #week_dates
Instance Method Details
#command ⇒ Object
31
32
33
34
|
# File 'lib/tempest_time/command.rb', line 31
def command
require 'tty-command'
TTY::Command.new
end
|
#date_prompt(message, days_before: 3, days_after: 3) ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/tempest_time/command.rb', line 56
def date_prompt(message, days_before: 3, days_after: 3)
require 'tty-prompt'
dates = dates_in_range(days_before: days_before, days_after: days_after)
TTY::Prompt.new.multi_select(
message,
dates,
per_page: 5,
default: dates.find_index { |k, v| v == Date.today } + 1
)
end
|
#execute ⇒ Object
18
19
20
21
22
|
# File 'lib/tempest_time/command.rb', line 18
def execute(*)
execute!
rescue TTY::Reader::InputInterrupt
prompt.say(pastel.yellow("\nGoodbye!"))
end
|
#execute! ⇒ Object
24
25
26
27
28
29
|
# File 'lib/tempest_time/command.rb', line 24
def execute!(*)
raise(
NotImplementedError,
"#{self.class}##{__method__} must be implemented"
)
end
|
#pastel(**options) ⇒ Object
36
37
38
39
|
# File 'lib/tempest_time/command.rb', line 36
def pastel(**options)
require 'pastel'
Pastel.new(options)
end
|
#prompt(**options) ⇒ Object
41
42
43
44
|
# File 'lib/tempest_time/command.rb', line 41
def prompt(**options)
require 'tty-prompt'
TTY::Prompt.new(options)
end
|
#spinner ⇒ Object
67
68
69
70
|
# File 'lib/tempest_time/command.rb', line 67
def spinner
require 'tty-spinner'
TTY::Spinner
end
|
#table ⇒ Object
72
73
74
75
|
# File 'lib/tempest_time/command.rb', line 72
def table
require 'tty-table'
TTY::Table
end
|
#week_prompt(message, past_weeks: 51) ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/tempest_time/command.rb', line 46
def week_prompt(message, past_weeks: 51)
require 'tty-prompt'
weeks = past_week_selections(past_weeks)
TTY::Prompt.new.select(
message,
weeks,
per_page: 5
)
end
|
#with_spinner(message, format: :pong) {|s| ... } ⇒ Object
77
78
79
80
81
|
# File 'lib/tempest_time/command.rb', line 77
def with_spinner(message, format: :pong)
s = spinner.new(":spinner #{message}", format: format)
s.auto_spin
yield(s)
end
|
#with_success_fail_spinner(message, format: :spin_3) ⇒ Object
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/tempest_time/command.rb', line 83
def with_success_fail_spinner(message, format: :spin_3)
s = spinner.new(":spinner #{message}", format: format)
s.auto_spin
response = yield
if response.success?
s.success(pastel.green(response.message))
else
s.error(pastel.red(response.message))
end
end
|