OILS / trees / medo.sh View on Github | oilshell.org

80 lines, 43 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# trees/medo.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10die() {
11 echo "$@" >&2
12 exit 1
13}
14
15main() {
16 local action=${1:-}
17
18 case $action in
19
20 sync)
21 local medo_dir=${2:-''}
22 local dest=${3:-'.'}
23
24 if test -z "$medo_dir"; then
25 die "$0: sync MEDO_DIR DEST"
26 fi
27
28 # Each vref should be sync'd
29 # It can have "blobsum" or "treesum", but at first we only support "blobsum"
30 # And then we look that up
31
32 find $medo_dir -name '*.vref' | xargs echo TODO
33
34 # Make the 00/ object dirs on demand
35 ;;
36
37 add-dir)
38 # Makes a vref and tarball that you can scp/rsync
39 local dir=${2:-''}
40 local vref=${3:-}
41
42 if test -z "$dir"; then
43 die "$0: add-dir DIR VREF"
44 fi
45
46 ;;
47
48 verify)
49 local dir=${2:-'.'}
50 local dest=${3:-}
51
52 echo 'TODO: checksum all files'
53 ;;
54
55 reachable)
56 local medo_dir=${2:-'.'}
57
58 if test -z "$medo_dir"; then
59 die "$0: reachable MEDO_DIR"
60 fi
61
62 # TODO: print a list of vblob IDs that are reachable to stdout. Then you
63 # can:
64 #
65 # - Check if they exist on the remote vat
66 # - Copy them to a new vat
67 # - You can also walk the git history, etc.
68
69 find $medo_dir -name '*.vref' | xargs echo TODO
70
71 ;;
72
73 *)
74 die "Invalid action '$action'"
75 ;;
76
77 esac
78}
79
80main "$@"