Class: Nin::Command
Constant Summary collapse
- COMMANDS_WITH_ARGS =
%w(a e c ac d)
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(command, args, config = {}) ⇒ Command
constructor
A new instance of Command.
Constructor Details
Instance Method Details
#call ⇒ Object
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 56 57 58 59 |
# File 'lib/nin/command.rb', line 14 def call case @command when 'l', 'list' @todo.list when 'a', 'add' desc, date, = parse_item_desc(@args.join(' ')) @todo.add(desc, date, ) when 'e', 'edit' desc, date, = parse_item_desc(@args[1..-1].join(' ')) @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}") when 'v', 'version' puts "nin #{Nin::VERSION}" 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|l] List all unarchived todos. Pass optional argument `a` to list all todos or `l` to list local todos only" 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)|c Un/archive todo(s) or pass `c` to archive all completed items" 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" puts "\tv | version Print current version of nin" end end |