]> arthur.barton.de Git - bup.git/blob - lib/cmd/init-cmd.py
Move cmd to lib/ and reverse symlink
[bup.git] / lib / cmd / init-cmd.py
1 #!/bin/sh
2 """": # -*-python-*-
3 bup_python="$(dirname "$0")/bup-python" || exit $?
4 exec "$bup_python" "$0" ${1+"$@"}
5 """
6 # end of bup preamble
7
8 from __future__ import absolute_import
9 import sys
10
11 from bup import git, options, client
12 from bup.helpers import log, saved_errors
13 from bup.compat import argv_bytes
14
15
16 optspec = """
17 [BUP_DIR=...] bup init [-r host:path]
18 --
19 r,remote=  remote repository path
20 """
21 o = options.Options(optspec)
22 (opt, flags, extra) = o.parse(sys.argv[1:])
23
24 if extra:
25     o.fatal("no arguments expected")
26
27
28 try:
29     git.init_repo()  # local repo
30 except git.GitError as e:
31     log("bup: error: could not init repository: %s" % e)
32     sys.exit(1)
33
34 if opt.remote:
35     git.check_repo_or_die()
36     cli = client.Client(argv_bytes(opt.remote), create=True)
37     cli.close()