Class: WorkingTimes::CLI
- Inherits:
-
Thor
- Object
- Thor
- WorkingTimes::CLI
- Includes:
- State
- Defined in:
- lib/working_times/cli.rb
Instance Method Summary collapse
- #finish(comment = '') ⇒ Object (also: #fi)
- #init(workon, term = 'default', company = '') ⇒ Object
- #invoice ⇒ Object
- #rest(duration) ⇒ Object
- #start(comment = '') ⇒ Object (also: #st)
- #version ⇒ Object
Instance Method Details
#finish(comment = '') ⇒ Object Also known as: fi
38 39 40 41 42 43 44 45 46 |
# File 'lib/working_times/cli.rb', line 38 def finish(comment = '') unless working? puts 'You are not starting work. Execute "wt start" to start working.' return end Record.new(timestamp: DateTime.now, comment: comment).finish finish_work end |
#init(workon, term = 'default', company = '') ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/working_times/cli.rb', line 9 def init(workon, term = 'default', company = '') if Dir.exist?(workon) puts "WORKON '#{workon}' is already created. Or name conflicted.'" return end FileUtils.mkdir_p(File.join(workon, 'terms')) FileUtils.mkdir_p(File.join(workon, 'invoices')) initialize_wtconf(workon, term, company) end |
#invoice ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/working_times/cli.rb', line 63 def invoice Invoice.new.tap do |invoice| invoice.generate invoice.build if [:build] end puts "Invoice created to #{path_invoice_current_term}." end |
#rest(duration) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/working_times/cli.rb', line 52 def rest(duration) unless working? puts 'You are not starting work. Execute "wt start" to start working.' return end Record.new(timestamp: DateTime.now, duration: duration).rest end |
#start(comment = '') ⇒ Object Also known as: st
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/working_times/cli.rb', line 21 def start(comment = '') if working? puts "You are already on working at #{current_work}." puts "To finish this, execute 'wt finish'." return end initialize_term_log Record.new(timestamp: DateTime.now, comment: comment).start start_work end |
#version ⇒ Object
72 73 74 |
# File 'lib/working_times/cli.rb', line 72 def version puts 'version: ' + VERSION end |