Class: Pedant::Cli

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

Class Method Summary collapse

Class Method Details

.runObject



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
60
61
62
63
64
65
66
# File 'lib/pedant/cli.rb', line 31

def self.run
  cfg = {}

  Command.initialize!

  optparse = OptionParser.new do |opts|
    opts.banner = "Usage: pedant [options] [command [args]]"

    cfg[:verbose] = 0
    opts.on('-v', '--verbose', 'Output more information') do
      cfg[:verbose] += 1
    end
  end

  optparse.parse!

  # Sanity check the command line arguments.
  if ARGV.empty?
    puts "No command was specified."
    puts
    usage
    exit 1
  end

  cmd = ARGV.shift
  cls = Command.find(cmd)
  if cls.nil? then
    puts "Command '#{cmd}' not supported."
    puts
    usage
    exit 1
  end

  # Run the command.
  cls.run(cfg, ARGV)
end

.usageObject



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/pedant/cli.rb', line 68

def self.usage
  puts "pedant [flags] [command] [filename ...]"
  puts
  puts "Flags:"
  puts "    -v       Display more verbose (warning) messages. "
  puts "    -vv      Display more verbose (informational) messages. "
  puts
  puts "Commands:"
  puts "    check    Runs all included checks against the specified plugin(s)."
  puts "    test     Runs the specified unit tests, all are selected by default."
end