Sha256: 059c115f1c126cce762e9c398cdf6c76e990dc96b9b089470927f4f4bca79f58

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require 'thor'
require 'taps/config'

Taps::Config.taps_database_url = ENV['TAPS_DATABASE_URL'] || 'sqlite://taps.db'

module Taps
class Cli < Thor
	desc "server <local_database_url> <login> <password>", "Start a taps database import/export server"
	method_options(:port => :numeric)
	def server(database_url, login, password)
		Taps::Config.database_url = database_url
		Taps::Config.login = login
		Taps::Config.password = password

		port = options[:port] || 5000

		Taps::Config.verify_database_url

		require 'taps/server'
		Taps::Server.run!({
			:port => port,
			:environment => :production,
			:logging => true
		})
	end

	desc "pull <local_database_url> <remote_url>", "Pull a database from a taps server"
	method_options(:chunksize => :numeric)
	def pull(database_url, remote_url)
		clientxfer(:cmd_receive, database_url, remote_url)
	end

	desc "push <local_database_url> <remote_url>", "Push a database to a taps server"
	method_options(:chunksize => :numeric)
	def push(database_url, remote_url)
		clientxfer(:cmd_send, database_url, remote_url)
	end

	desc "version", "Taps version"
	def version
		puts Taps.version
	end

	def clientxfer(method, database_url, remote_url)
		if options[:chunksize]
			Taps::Config.chunksize = options[:chunksize] < 100 ? 100 : options[:chunksize]
		else
			Taps::Config.chunksize = 1000
		end
		Taps::Config.database_url = database_url
		Taps::Config.remote_url = remote_url

		Taps::Config.verify_database_url

		require 'taps/client_session'

		Taps::ClientSession.quickstart do |session|
			session.send(method)
		end
	end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
matthewtodd-taps-0.2.19 lib/taps/cli.rb