]> arthur.barton.de Git - bup.git/blob - lib/bup/cmd/init.py
Remove Client __del__ in favor of context management
[bup.git] / lib / bup / cmd / init.py
1
2 from __future__ import absolute_import
3 import sys
4
5 from bup import git, options, client
6 from bup.helpers import log
7 from bup.compat import argv_bytes
8
9
10 optspec = """
11 [BUP_DIR=...] bup init [-r host:path]
12 --
13 r,remote=  remote repository path
14 """
15
16 def main(argv):
17     o = options.Options(optspec)
18     opt, flags, extra = o.parse_bytes(argv[1:])
19
20     if extra:
21         o.fatal("no arguments expected")
22
23     try:
24         git.init_repo()  # local repo
25     except git.GitError as e:
26         log("bup: error: could not init repository: %s" % e)
27         sys.exit(1)
28
29     if opt.remote:
30         git.check_repo_or_die()
31         with client.Client(argv_bytes(opt.remote), create=True):
32             pass