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