]> arthur.barton.de Git - bup.git/blob - cmd/init-cmd.py
f2c0052bd5fd0d16811d8d809f52e8819c2c85a4
[bup.git] / 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 import sys
9
10 from bup import git, options, client
11 from bup.helpers import log, saved_errors
12
13
14 optspec = """
15 [BUP_DIR=...] bup init [-r host:path]
16 --
17 r,remote=  remote repository path
18 """
19 o = options.Options(optspec)
20 (opt, flags, extra) = o.parse(sys.argv[1:])
21
22 if extra:
23     o.fatal("no arguments expected")
24
25
26 try:
27     git.init_repo()  # local repo
28 except git.GitError as e:
29     log("bup: error: could not init repository: %s" % e)
30     sys.exit(1)
31
32 if opt.remote:
33     git.check_repo_or_die()
34     cli = client.Client(opt.remote, create=True)
35     cli.close()