Class: Nin::Command
- Inherits:
-
Object
- Object
- Nin::Command
- Defined in:
- lib/nin/command.rb
Constant Summary collapse
- COMMANDS_WITH_ARGS =
%w(a e c ac d)
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(command, args) ⇒ Command
constructor
A new instance of Command.
Constructor Details
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nin/command.rb', line 13 def call case @command when 'l' @todo.list when 'a' desc, date, = Parser.new(@args.join(' ')).call @todo.add(desc, date, ) when 'e' desc, date, = Parser.new(@args[1..-1].join(' ')).call @todo.edit(@args[0].to_i, desc, date, ) when 'c' @todo.complete(*@args) when 'ac' @todo.archive(*@args) when 'd' @todo.delete(*@args) when 'gc' @todo.delete_archived when 'o' system("`echo $EDITOR` #{@todo.store.file}") when 'i' run_interactive_mode else puts "NAME:\n\tnin - a simple, full-featured command line todo app" puts "\nUSAGE:\n\tnin COMMAND [arguments...]" puts "\nCOMMANDS:" puts "\tl [a] List all unarchived todos. Pass optional argument `a` to list all todos" puts "\ta desc Add a todo. Prepend due date by a @. Prepend each tag by a \\#" puts "\te id desc Edit a todo. Prepend due date by a @. Prepend each tag by a \\#" puts "\tc id(s) Un/complete todo(s)" puts "\tac id(s) Un/archive todo(s)" puts "\td id(s) Delete todo(s)" puts "\tgc Delete all archived todos. Resets item ids as a side effect" puts "\to Open todo file in $EDITOR" end end |