Module: Outliers::CLI

Defined in:
lib/outliers/cli.rb,
lib/outliers/cli/process.rb

Defined Under Namespace

Classes: Process

Class Method Summary collapse

Class Method Details

.commandsObject



45
46
47
48
49
# File 'lib/outliers/cli.rb', line 45

def self.commands
  return @commands if @commands
  klasses   = Outliers::CLI.constants
  @commands = klasses.map { |klass| Outliers::CLI.const_get(klass).new }
end

.length_of_longest_commandObject



51
52
53
# File 'lib/outliers/cli.rb', line 51

def self.length_of_longest_command
  commands.map { |c| c.command_name.length }.max
end

.startObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/outliers/cli.rb', line 8

def self.start
  cmd = ARGV.shift

  case cmd
  when 'process'
    begin
      CLI::Process.new.process
    rescue OptionParser::MissingArgument => e
      puts e.message
      exit 1
    end
  when '-v'
    puts OUTLIERS::VERSION
  else
    puts "Unknown command: '#{cmd}'."
    puts ''
    usage
    exit 1
  end
end

.usageObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/outliers/cli.rb', line 29

def self.usage
  puts 'Usage: outliers command'
  puts ''
  puts 'Append -h for help on specific subcommand.'
  puts ''
  puts 'See http://brettweavnet.github.io/outliers for documentation.'
  puts ''

  puts 'Commands:'
  commands.each do |cmd|
    $stdout.printf "    %-#{length_of_longest_command}s      %s\n",
                   cmd.command_name,
                   cmd.command_summary
  end
end