Sha256: 46a12d0acc29c15198d6d465857c6ed7b96f5fe250b28a35b4d64ae75d90fb5b

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

module TrelloCli
  module CLI
    class Run
      def run
        target = ARGV.shift
        cmd    = ARGV.shift || 'help'

        case target
        when *targets
          target_object = CLI.const_get(target.capitalize).new

          cmd = 'help' unless target_object.actions.include?(cmd.to_sym)

          target_object.send cmd 
        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 == :Shared )
        end
        klasses.map { |k| k.to_s.downcase }
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trello_cli-0.0.1 lib/trello_cli/cli/run.rb