Class: Todoloo::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/todoloo/cli.rb

Constant Summary collapse

DEFAULT_PATTERN =
[
  "**/*.rb",
  "*.rb"
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/todoloo/cli.rb', line 39

def self.exit_on_failure?
  true
end

Instance Method Details

#ioObject



31
32
33
34
35
36
37
# File 'lib/todoloo/cli.rb', line 31

def io
  Todoloo::TaskList.new.add(
    Todoloo::Parser
      .new
      .parse_and_transform($stdin.read)
  ).sort.write($stdout)
end

#scanObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/todoloo/cli.rb', line 16

def scan
  patterns = options.fetch(:pattern, DEFAULT_PATTERN)

  Todoloo::FileScanner
    .new(
      patterns,
      excludes: options.fetch(:exclude, []),
      trace: options.fetch(:verbose)
    )
    .scan
    .sort
    .write(options.fetch(:output))
end