Sha256: 58ea60eec55aeec218ca2f5317f40e73de68a8e361fb6860f8ba06ee8ab31546
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
#! /usr/bin/env ruby # require 'todo' require 'main' Main { mode "add" do argument("task"){ cast :string } option('list', 'l'){ argument :optional description 'pass a list to add a task to' } def run app = Todo::Application.new(persistent: true) app.add(name:params['task'].value, list: params['list'].value) app.tasks end end mode "tasks" do option("list", 'l') { argument :optional } def run app = Todo::Application.new(persistent: true) app.tasks(verbose: true, list: params["list"].value) end end mode "remove" do argument("task"){ cast :string } option("list", "l"){ argument :optional } def run app = Todo::Application.new(persistent: true) allowed = ["Y", "N", "yes", "no"] allowed_positives = ["Y", "yes", "y", "Yes"] allowed_negatives = ["N", "no", "n", "No"] command ="" until(allowed_positives.include?(command) || allowed_negatives.include?(command)) print "Are you sure you want to remove this task? (Y/N) " command = stdin.gets.chomp end if allowed_positives.include?(command) task = params["task"].value app.remove(task) puts "task:#{task} removed" app.tasks(verbose: true) end end end mode "finish" do argument("task") { cast :string } option("list", "l") { argument :optional } def run app = Todo::Application.new(persistent: true) app.finish(params["task"].value, list: params["list"].value) end end mode "lists" do argument("list"){ optional cast :string description "the sublist to access" } def run app =Todo::Application.new(persistent: true) params["list"].given? ? app.access_list(params["list"].value) : app.lists end end }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
2do-0.0.2 | bin/todo |