lib/bullit.rb in bullit-0.1.0 vs lib/bullit.rb in bullit-0.1.1
- old
+ new
@@ -30,23 +30,29 @@
option "--text", "TEXT", "what the task is"
def execute
prompt = TTY::Prompt.new
text = prompt.ask('what do you need to do?') if text.nil?
BulletJournal::File.add_task(text)
+ show_tasks
end
end
subcommand "complete", "complete a task" do
parameter "TASK_NUMBER", "what the task is", required: true
def execute
BulletJournal::File.complete_task(task_number.to_i)
+ show_tasks
end
end
end
def show_tasks
- tasks = BulletJournal::File.today_tasks.each_with_index.map{ |t,i| [i,t[:text], t[:complete] == true ? ' ✅' : ' ❌']}
+ if tasks = BulletJournal::File.today_tasks
+ tasks = tasks.each_with_index.map{ |t,i| [i,t[:text], t[:complete] == true ? ' ✅' : ' ❌']}
- puts TTY::Table.new(['#', 'Task', ''], tasks).render(:ascii)
+ puts TTY::Table.new(['#', 'Task', ''], tasks).render(:unicode)
+ elsif tasks == {}
+ puts "There's no tasks for today"
+ end
end
end
end