]> arthur.barton.de Git - bup.git/blob - cmd/rm-cmd.py
Adjust rm-cmd and bup.rm for python 3 and enable test-rm
[bup.git] / cmd / rm-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.compat import argv_bytes
12 from bup.git import check_repo_or_die
13 from bup.options import Options
14 from bup.helpers import die_if_errors, handle_ctrl_c, log
15 from bup.repo import LocalRepo
16 from bup.rm import bup_rm
17
18 optspec = """
19 bup rm <branch|save...>
20 --
21 #,compress=  set compression level to # (0-9, 9 is highest) [6]
22 v,verbose    increase verbosity (can be specified multiple times)
23 unsafe       use the command even though it may be DANGEROUS
24 """
25
26 handle_ctrl_c()
27
28 o = Options(optspec)
29 opt, flags, extra = o.parse(sys.argv[1:])
30
31 if not opt.unsafe:
32     o.fatal('refusing to run dangerous, experimental command without --unsafe')
33
34 if len(extra) < 1:
35     o.fatal('no paths specified')
36
37 check_repo_or_die()
38 repo = LocalRepo()
39 bup_rm(repo, [argv_bytes(x) for x in extra],
40        compression=opt.compress, verbosity=opt.verbose)
41 die_if_errors()