Class: Redpomo::CLI
- Inherits:
-
Thor
- Object
- Thor
- Redpomo::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/redpomo/cli.rb
Instance Method Summary collapse
- #add(subject = nil) ⇒ Object
- #close(task_number) ⇒ Object
- #init(path = '~/.redpomo') ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #open(task_number) ⇒ Object
- #pull ⇒ Object
- #push(path = nil) ⇒ Object
- #start(task_number) ⇒ Object
Constructor Details
Instance Method Details
#add(subject = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/redpomo/cli.rb', line 31 def add(subject = nil) description = @options[:description] if subject.blank? = Tempfile.new('issue').path + ".textile" template "issue_stub.textile", , verbose: false subject, description = open_editor() end issue = Task.new(nil, subject).to_issue issue.description = description if issue.tracker.present? issue.create! task = issue.to_task task.add! Redpomo.ui.info "Issue created, see it at #{task.url}" else Redpomo.ui.error "Cannot create issue, unknown tracker." exit 1 end end |
#close(task_number) ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/redpomo/cli.rb', line 119 def close(task_number) task = TaskList.find(task_number) task.done! task.close_issue!(@options[:message]) Redpomo.ui.info "Issue updated, see it at #{task.url}" end |
#init(path = '~/.redpomo') ⇒ Object
128 129 130 131 132 |
# File 'lib/redpomo/cli.rb', line 128 def init(path = '~/.redpomo') path = File.(path) template "config.yml", path, verbose: false open_editor(path) end |
#open(task_number) ⇒ Object
106 107 108 109 |
# File 'lib/redpomo/cli.rb', line 106 def open(task_number) task = TaskList.find(task_number) task.open_in_browser! end |
#pull ⇒ Object
56 57 58 |
# File 'lib/redpomo/cli.rb', line 56 def pull TaskList.pull_from_trackers! end |
#push(path = nil) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/redpomo/cli.rb', line 63 def push(path = nil) csv = if path.present? File.read(File.(path)) else require 'applescript' AppleScript.execute('tell application "Pomodoro" to take log') end if csv.blank? if path.present? Redpomo.ui.error "Empty CSV provided!" else Redpomo.ui.error "Empty Pomodoro log!" Redpomo.ui.info "Maybe you need to this Pomodoro fork? https://github.com/stefanoverna/pomodoro" end exit 1 end entries = Entry.load_from_csv(csv) entries = FuzzyConverter.convert(entries) if @options[:fuzzy] unpushable_entries = entries.select {|entry| !entry.pushable? } if unpushable_entries.any? Redpomo.ui.error "Some pomodoros cannot be associated with a proper issue/project." EntriesPrinter.print(unpushable_entries) exit 1 end if @options[:dry_run] EntriesPrinter.print(entries) else entries.each(&:push!) Redpomo.ui.info "Pushed #{entries.count} time entries" if path.blank? AppleScript.execute('tell application "Pomodoro" to clear') Redpomo.ui.info "Cleared Pomodoro.app log" end end end |