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 49 50 51 52 53 54 55 |
# File 'lib/nin/command.rb', line 13 def call case @command when 'l', 'list' @todo.list when 'a', 'add' desc, date, = Parser.new(@args.join(' ')).call @todo.add(desc, date, ) when 'e', 'edit' desc, date, = Parser.new(@args[1..-1].join(' ')).call @todo.edit(@args[0].to_i, desc, date, ) when 'p', 'prioritize' @todo.prioritize(@args[0].to_i, @args[1].to_i) when 'c', 'complete' @todo.complete(*@args) when 'ac', 'archive' @todo.archive(*@args) when 'd', 'delete' @todo.delete(*@args) when 'gc', 'garbage' @todo.delete_archived when 's', 'analyze' @todo.analyze when 'i', 'repl' run_interactive_mode when 'o', 'open' system("`echo $EDITOR` #{@todo.store.file}") else puts "NAME:\n\tnin - a simple, full-featured command line todo app" puts "\nUSAGE:\n\tnin COMMAND [arguments...]" puts "\nCOMMANDS:" puts "\tl | list [a] List all unarchived todos. Pass optional argument `a` to list all todos" puts "\ta | add desc Add a todo. Prepend due date by a @. Prepend each tag by a \\#" puts "\te | edit id desc Edit a todo. Prepend due date by a @. Prepend each tag by a \\#" puts "\tp | prioritize id step Prioritize a todo by either a positive or negative step within its date group" puts "\tc | complete id(s) Un/complete todo(s)" puts "\tac | archive id(s) Un/archive todo(s)" puts "\td | delete id(s) Delete todo(s)" puts "\tgc | garbage Delete all archived todos. Resets item ids as a side effect" puts "\ts | analyze Analyze tasks and print statistics" puts "\ti | repl Open nin in REPL mode" puts "\to | open Open todo file in $EDITOR" end end |