Sha256: ee306f2339a2be8cc16968cc2f464c71959b8a5ee56ec40bbe196ac6942f4767
Contents?: true
Size: 1.74 KB
Versions: 4
Compression:
Stored size: 1.74 KB
Contents
require 'optparse' require 'outliers/cli/evaluate' require 'outliers/cli/process' require 'outliers/cli/providers' require 'outliers/cli/resources' module Outliers module CLI def self.start cmd = ARGV.shift case cmd when 'evaluate' begin CLI::Evaluate.new.evaluate rescue OptionParser::MissingArgument => e puts e.message exit 1 end when 'providers' begin CLI::Providers.new.providers rescue OptionParser::MissingArgument => e puts e.message exit 1 end when 'process' begin CLI::Process.new.process rescue OptionParser::MissingArgument => e puts e.message exit 1 end when 'resources' begin CLI::Resources.new.resources 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 def self.usage puts 'Usage: outliers command' puts '' puts 'Append -h for help on specific subcommand.' puts '' puts 'Commands:' commands.each do |cmd| $stdout.printf " %-#{length_of_longest_command}s %s\n", cmd.command_name, cmd.command_summary end end def self.commands return @commands if @commands klasses = Outliers::CLI.constants @commands = klasses.map { |klass| Outliers::CLI.const_get(klass).new } end def self.length_of_longest_command commands.map { |c| c.command_name.length }.max end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
outliers-0.2.0 | lib/outliers/cli.rb |
outliers-0.1.1 | lib/outliers/cli.rb |
outliers-0.1.0 | lib/outliers/cli.rb |
outliers-0.0.1 | lib/outliers/cli.rb |