Sha256: 15f01f3abe0a3b22e12351dc1172d7af9488027df6cf00ee9709193b98d9942d

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'tmpdir'

require 'bitcoin/cli' # circular dependency on CLI for CommandError
require 'bitcoin/commands/satoshi_wallet'
require 'bitcoin/data_access/satoshi/satoshi_wallet'
require 'bitcoin/domain/bitcoin_address'
require 'bitcoin/filesystem/empty_temp_dir'

module Bitcoin
  module Commands
    class SatoshiWalletCommand
      TEMP_DB_PATH = "bitcoinrb_db_tmp"

      def initialize(stream_bundle, command_environment)
        @stream_bundle = stream_bundle
        @command_environment = command_environment
      end

      def run(args)
        command_name, *remaining_args = *args
        command_class =
          case command_name
          when "add-address"
            SatoshiWallet::AddAddressCommand
          when "show-addresses"
            SatoshiWallet::ShowAddressesCommand
          when "show-version"
            SatoshiWallet::ShowVersionCommand
          else
            @stream_bundle.puts_error(%'Unknown satoshi-wallet subcommand: "#{command_name}"')
            raise CLI::CommandError.new
          end
        @command_environment.run_command(command_class.new(@stream_bundle), remaining_args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitcoin-0.1.2 ./lib/bitcoin/commands/satoshi_wallet_command.rb