Class: Todo::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/tasky.rb

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



9
10
11
12
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
# File 'lib/tasky.rb', line 9

def self.parse(args)
  options = {}

  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: example.rb [options]"

    opts.on("-l", "--list", "Print todo tasks") do
      Todo.print_tasks
    end

    opts.on("-d", "--done", "Print done tasks") do
      Todo.print_tasks(:done)
    end

    opts.on("-e", "--edit", "Edit tasks file") do
      Todo.edit
    end

    opts.on_tail("-h", "--help", "Prints this help") do
      puts opts
      exit
    end

    opts.on_tail("-v", "--version", "Prints version") do
      puts "todo #{VERSION}"
      exit
    end
  end

  opt_parser.parse!(args)
  options
end