Sha256: 3ef466f0d147e686208e49403a257b64bb6a52f7ce05578a113a29e1f55e2448

Contents?: true

Size: 837 Bytes

Versions: 6

Compression:

Stored size: 837 Bytes

Contents

# frozen_string_literal: true

require 'optparse'
require 'optparse/uri'
require 'ostruct'

module Mcoin
  # The command line interface
  module Command
    autoload :Base, 'mcoin/command/base'
    autoload :Common, 'mcoin/command/common'
    autoload :Ticker, 'mcoin/command/ticker'

    autoload :HasMarket, 'mcoin/command/ext/has_market'
    autoload :HasPair, 'mcoin/command/ext/has_pair'
    autoload :Saveable, 'mcoin/command/ext/saveable'

    class << self
      def execute
        pick.new.parse!.execute
      end

      def pick
        command = ARGV.first&.capitalize
        return Common unless commands.include?(command&.to_sym)
        const_get(command)
      end

      def commands
        constants.select do |klass|
          const_get(klass).is_a?(Class)
        end - %i[Base Common]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mcoin-0.6.1 lib/mcoin/command.rb
mcoin-0.6.0 lib/mcoin/command.rb
mcoin-0.5.2 lib/mcoin/command.rb
mcoin-0.5.1 lib/mcoin/command.rb
mcoin-0.5.0 lib/mcoin/command.rb
mcoin-0.4.0 lib/mcoin/command.rb