Sha256: 78d304380425f8dd757c49f0a9e66daff1e25d72afc31a7c972eb77c207170b0

Contents?: true

Size: 837 Bytes

Versions: 3

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 :HasType, 'mcoin/command/ext/has_type'
    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

3 entries across 3 versions & 1 rubygems

Version Path
mcoin-0.3.0 lib/mcoin/command.rb
mcoin-0.2.1 lib/mcoin/command.rb
mcoin-0.2.0 lib/mcoin/command.rb