Sha256: fa0a63f4b61ead052b1d80c6df1ac4cb5f2fce55c6b266475e732ada56860200

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require "thor"

class Todoloo::CLI < Thor
  package_name "Todoloo"

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

  desc "scan", "Scans all files that match the given globs and outputs a tasks.yml"
  method_option :pattern, type: :string, repeatable: true, aliases: "-p", desc: "Path globs to match; can be repeated"
  method_option :exclude, type: :string, repeatable: true, aliases: "-e", desc: "List of path globs to exclude"
  method_option :output, type: :string, aliases: "-o", default: "tasks.yml", desc: "Name of the output file"
  method_option :verbose, type: :boolean, default: false
  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

  desc "io", "Reads input from stdio and writes to stdout"
  def io
    Todoloo::TaskList.new.add(
      Todoloo::Parser
        .new
        .parse_and_transform($stdin.read)
    ).sort.write($stdout)
  end

  def self.exit_on_failure?
    true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
todoloo-0.0.4 lib/todoloo/cli.rb