Class: Rubdo::CLI
- Inherits:
-
Object
- Object
- Rubdo::CLI
- Defined in:
- lib/rubdo/cli.rb
Instance Method Summary collapse
- #add ⇒ Object
- #done ⇒ Object (also: #rm)
- #edit ⇒ Object
- #help ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #list ⇒ Object (also: #ls)
Constructor Details
Instance Method Details
#add ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/rubdo/cli.rb', line 11 def add if ARGV[1] @list.add ARGV[1] else Tempfile.open('new_task') { |tf| @list.add Rubdo::Editor.add(tf.path) } end save end |
#done ⇒ Object Also known as: rm
20 21 22 23 |
# File 'lib/rubdo/cli.rb', line 20 def done @list.done @id save end |
#edit ⇒ Object
31 32 33 34 35 |
# File 'lib/rubdo/cli.rb', line 31 def edit abort("not a valid id") if @id > @list.to_a.size Tempfile.open('new_description') { |tf| task.description = Rubdo::Editor.edit(tf.path, task.description) } save end |
#help ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubdo/cli.rb', line 37 def help puts <<-HELP ----------------- add/a [task description] - Add a new task. If the description is empty, $EDITOR is opened list/ls - Lists all tasks done/d [task id] - Complete a task edit/e [task id] - Opens up $EDITOR to edit the task description remove/rm [task id] - Deletes the specific task, same as done help - Prints out this information HELP end |
#list ⇒ Object Also known as: ls
26 27 28 |
# File 'lib/rubdo/cli.rb', line 26 def list list_tasks unless @list.to_a.empty? end |