class Sloc::CLI

Attributes

help[R]
options[R]

Public Class Methods

new() click to toggle source
# File lib/sloc/cli.rb, line 6
def initialize
  @options = {}
end

Public Instance Methods

help?() click to toggle source
# File lib/sloc/cli.rb, line 49
def help?
  @paths.empty? || @options[:help]
end
parse_options(args) click to toggle source
# File lib/sloc/cli.rb, line 35
def parse_options(args)
  opts = Slop.parse!(args) do |o|
    o.on('-h', '--help', 'Display this help message.')
    o.on('-o', '--order=', 'Specify key to order by.')
    o.on('--desc', 'Reverse order if specified')
    o.on('-l', '--limit=', 'Specify key to set limitation of displaying file number.')
  end

  [opts, args]
end
report(args = ARGV) click to toggle source
# File lib/sloc/cli.rb, line 19
def report(args = ARGV)
  setup(args)
  if help?
    help
  else
    @runner.report(@paths)
  end
end
run(args = ARGV) click to toggle source
# File lib/sloc/cli.rb, line 10
def run(args = ARGV)
  setup(args)
  if help?
    puts help
  else
    puts @runner.run(@paths)
  end
end
setup(args) click to toggle source
# File lib/sloc/cli.rb, line 28
def setup(args)
  @options, @paths = parse_options(args)
  @runner = Runner.new(@options)

  nil
end