]> arthur.barton.de Git - bup.git/blob - lib/cmd/rm-cmd.py
Split src tree python use to config/bin/python and dev/bup-python
[bup.git] / lib / cmd / rm-cmd.py
1 #!/bin/sh
2 """": # -*-python-*-
3 # https://sourceware.org/bugzilla/show_bug.cgi?id=26034
4 export "BUP_ARGV_0"="$0"
5 arg_i=1
6 for arg in "$@"; do
7     export "BUP_ARGV_${arg_i}"="$arg"
8     shift
9     arg_i=$((arg_i + 1))
10 done
11 # Here to end of preamble replaced during install
12 bup_python="$(dirname "$0")/../../config/bin/python" || exit $?
13 exec "$bup_python" "$0"
14 """
15 # end of bup preamble
16
17 from __future__ import absolute_import
18 import os.path, sys
19
20 sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
21
22 from bup import compat
23 from bup.compat import argv_bytes
24 from bup.git import check_repo_or_die
25 from bup.options import Options
26 from bup.helpers import die_if_errors, handle_ctrl_c, log
27 from bup.repo import LocalRepo
28 from bup.rm import bup_rm
29
30 optspec = """
31 bup rm <branch|save...>
32 --
33 #,compress=  set compression level to # (0-9, 9 is highest) [6]
34 v,verbose    increase verbosity (can be specified multiple times)
35 unsafe       use the command even though it may be DANGEROUS
36 """
37
38 handle_ctrl_c()
39
40 o = Options(optspec)
41 opt, flags, extra = o.parse(compat.argv[1:])
42
43 if not opt.unsafe:
44     o.fatal('refusing to run dangerous, experimental command without --unsafe')
45
46 if len(extra) < 1:
47     o.fatal('no paths specified')
48
49 check_repo_or_die()
50 repo = LocalRepo()
51 bup_rm(repo, [argv_bytes(x) for x in extra],
52        compression=opt.compress, verbosity=opt.verbose)
53 die_if_errors()