Class: TempestTime::Command
Direct Known Subclasses
TempestTime::Commands::Config::Edit, TempestTime::Commands::Config::Setup, TempestTime::Commands::Delete, TempestTime::Commands::Issue::List, TempestTime::Commands::Issue::Open, TempestTime::Commands::List, TempestTime::Commands::Report, 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, #end_of_week, #formatted_date, #formatted_date_range, #formatted_time, #formatted_time_for_input, #formatted_time_long, #parsed_time, #past_date_selections, #past_week_selections, #week_beginnings, #week_dates
Instance Method Details
#command ⇒ Object
24
25
26
27
|
# File 'lib/tempest_time/command.rb', line 24
def command
require 'tty-command'
TTY::Command.new
end
|
#date_prompt(message, past_days = 6) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/tempest_time/command.rb', line 49
def date_prompt(message, past_days = 6)
require 'tty-prompt'
dates = past_date_selections(past_days)
TTY::Prompt.new.select(
message,
dates,
per_page: 5
)
end
|
#execute ⇒ Object
17
18
19
20
21
22
|
# File 'lib/tempest_time/command.rb', line 17
def execute(*)
raise(
NotImplementedError,
"#{self.class}##{__method__} must be implemented"
)
end
|
#pastel(**options) ⇒ Object
29
30
31
32
|
# File 'lib/tempest_time/command.rb', line 29
def pastel(**options)
require 'pastel'
Pastel.new(options)
end
|
#prompt(**options) ⇒ Object
34
35
36
37
|
# File 'lib/tempest_time/command.rb', line 34
def prompt(**options)
require 'tty-prompt'
TTY::Prompt.new(options)
end
|
#spinner ⇒ Object
59
60
61
62
|
# File 'lib/tempest_time/command.rb', line 59
def spinner
require 'tty-spinner'
TTY::Spinner
end
|
#table ⇒ Object
64
65
66
67
|
# File 'lib/tempest_time/command.rb', line 64
def table
require 'tty-table'
TTY::Table
end
|
#week_prompt(message, past_weeks = 51) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/tempest_time/command.rb', line 39
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
69
70
71
72
73
|
# File 'lib/tempest_time/command.rb', line 69
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
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/tempest_time/command.rb', line 75
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
|