Class: Tcelfer::CLI::Base
- Inherits:
-
Thor
- Object
- Thor
- Tcelfer::CLI::Base
- Defined in:
- lib/tcelfer/cli.rb
Overview
Thor CLI for Tcelfer
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
Useful return codes are nice, of course.
Instance Method Summary collapse
- #day ⇒ Object
-
#initialize(*_args) ⇒ Base
constructor
A new instance of Base.
- #report ⇒ Object
- #version ⇒ Object
- #ytd ⇒ Object
Constructor Details
#initialize(*_args) ⇒ Base
Returns a new instance of Base.
30 31 32 33 34 35 |
# File 'lib/tcelfer/cli.rb', line 30 def initialize(*_args) # Quit on Ctrl-C please @prompt = TTY::Prompt.new(interrupt: :exit) super end |
Class Method Details
.exit_on_failure? ⇒ Boolean
Useful return codes are nice, of course
38 39 40 |
# File 'lib/tcelfer/cli.rb', line 38 def self.exit_on_failure? true end |
Instance Method Details
#day ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/tcelfer/cli.rb', line 55 def day Tcelfer.config.debug = [:verbose] store = Tcelfer::Storage.new tc_day = rec_day! store @prompt.say("Recorded [#{tc_day.date}]: #{Paint[tc_day., :bold]}") rescue Tcelfer::Error => e @prompt.error("[#{e.class}]", e) end |
#report ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/tcelfer/cli.rb', line 67 def report Tcelfer.config.debug = [:verbose] rep = Report.new @prompt.say(gen_report(rep, ['month'], ['year'], ['legend'])) rescue Tcelfer::Error => e @prompt.error("[#{e.class}]", e) end |
#version ⇒ Object
48 49 50 |
# File 'lib/tcelfer/cli.rb', line 48 def version puts Tcelfer::VERSION end |
#ytd ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/tcelfer/cli.rb', line 76 def ytd Tcelfer.config.debug = [:verbose] rep = Report.new 1.upto(Date.today.mon) do |mon| @prompt.say(rep.generate_month_report(mon)) end @prompt.say(Report.legend) rescue Tcelfer::Error => e @prompt.error("[#{e.class}]", e) end |