class TrelloDXY::CLI::Run
Public Instance Methods
run()
click to toggle source
# File lib/trello_dxy/cli/run.rb, line 4 def run target = ARGV.shift cmd = ARGV.shift || 'help' case target when *targets target_object = CLI::Commands.const_get(target.capitalize).new cmd = 'help' unless target_object.actions.include?(cmd.to_sym) begin target_object.send cmd rescue OptionParser::InvalidOption, OptionParser::MissingArgument puts $!.to_s puts optparse exit 1 rescue Trello::Error => e puts e.message exit 1 rescue TrelloDXY::Errors => e puts "error: #{e}" exit 1 rescue NoMethodError => e if e.message.match /SocketError/ puts 'Please connect to the internet to access Trello' exit 1 else raise e end end when '-v' puts TrelloDXY::Meta::VERSION else puts "Unkown target: '#{target}'." unless target == '-h' puts "trello_dxy [#{targets.join('|')}] [command] OPTIONS" puts "Append -h for help on specific target." end end
Private Instance Methods
targets()
click to toggle source
# File lib/trello_dxy/cli/run.rb, line 42 def targets klasses = TrelloDXY::CLI.constants.reject do |c| ( c == :Run ) || ( c == :Commands ) end klasses.map { |k| k.to_s.downcase } end