summaryrefslogtreecommitdiff
path: root/git-mirror-backend.rb
blob: 2be883080e1f8f2730d36a2ee7ce99a6ac43aa7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# coding: utf-8

require 'shellwords'

class GitMirrorBackend
	def repl(accountName)
		@accountName = accountName
		$stdin.each do |line|
			args = line.shellsplit
			args[0] = 'cmd_'+args[0].gsub('-', '_')
			out = self.send(*args)
			if out.nil?
				# do nothing
			elsif out.is_a? String
				puts out
			elsif out.is_a? Array
				out.each do |outline|
					puts outline
				end
			elsif out.is_a? Hash
				out.each do |k,v|
					puts "#{k}=#{v}"
				end
			else
				raise "I don't know what to do with output value: #{out}"
			end
		end
		self.finish
	end
	def finish
		# noop
	end
end