Skip to content

Commit ac118ca

Browse files
committed
Use arguments instead of options for source and target.
1 parent 60bb62a commit ac118ca

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

couchdb/tools/replicate.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ def main():
3232

3333
usage = '%prog [options]'
3434
parser = optparse.OptionParser(usage=usage)
35-
parser.add_option('--source-server',
36-
action='store',
37-
dest='source_url',
38-
help='the url of the server to replicate from')
39-
parser.add_option('--target-server',
40-
action='store',
41-
dest='target_url',
42-
default="http://127.0.0.1:5984",
43-
help='the url of the server to replicate to [%default]')
4435
parser.add_option('--database',
4536
action='append',
4637
dest='dbnames',
@@ -55,17 +46,17 @@ def main():
5546
help='trigger continuous replication in cochdb')
5647

5748
options, args = parser.parse_args()
58-
if not options.target_url or (not options.source_url):
59-
parser.error("Need at least --source-server and --target-server")
60-
sys.exit(1)
49+
if len(args) != 2:
50+
raise parser.error('need source and target arguments')
6151

62-
if not options.source_url.endswith('/'):
63-
options.source_url = options.source_url + '/'
64-
if not options.target_url.endswith('/'):
65-
options.target_url = options.target_url + '/'
52+
src, tgt = args
53+
if not src.endswith('/'):
54+
src += '/'
55+
if not tgt.endswith('/'):
56+
tgt += '/'
6657

67-
source_server = couchdb.client.Server(options.source_url)
68-
target_server = couchdb.client.Server(options.target_url)
58+
source_server = couchdb.client.Server(src)
59+
target_server = couchdb.client.Server(tgt)
6960

7061
if not options.dbnames:
7162
dbnames = sorted(i for i in source_server)
@@ -87,7 +78,7 @@ def main():
8778
if options.continuous:
8879
body['continuous'] = True
8980

90-
body.update({'source': '%s%s' % (options.source_url, dbname), 'target': dbname})
81+
body.update({'source': '%s%s' % (src, dbname), 'target': dbname})
9182
target_server.resource.post('_replicate', body)
9283
print '%.1fs' % (time.time() - start)
9384

0 commit comments

Comments
 (0)