Sha256: 968285e667119403633363edff04515da2f439c8e5dc3d311908cb9c9b0a1a6b
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
module TrelloCli module CLI class Run 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, Trello::Error => e puts e.message exit 1 rescue TrelloCli::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 TrelloCli::VERSION else puts "Unkown target: '#{target}'." unless target == '-h' puts "trello [#{targets.join('|')}] [command] OPTIONS" puts "Append -h for help on specific target." end end private def targets klasses = TrelloCli::CLI.constants.reject do |c| ( c == :Run ) || ( c == :Commands ) end klasses.map { |k| k.to_s.downcase } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
trello_cli-0.4.1 | lib/trello_cli/cli/run.rb |
trello_cli-0.4.0 | lib/trello_cli/cli/run.rb |