forked from balena-os/librsync-go
/
main.go
59 lines (55 loc) · 1.21 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"os"
"log"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "rdiff"
app.Usage = "binary diff utility based on librsync-go"
app.Version = "v0.0.1"
app.Author = "Petros Angelatos"
app.Email = "petrosagg@gmail.com"
app.Action = cli.ShowAppHelp
app.Commands = []cli.Command{
{
Name: "signature",
Usage: "creates a signature of the input file",
ArgsUsage: "BASIS SIGNATURE",
Action: CommandSignature,
Flags: []cli.Flag{
cli.UintFlag{
Name: "block-size, b",
Value: 2048,
Usage: "Signature block size",
},
cli.UintFlag{
Name: "sum-size, S",
Value: 32,
Usage: "Set signature strength",
},
cli.StringFlag{
Name: "hash, H",
Value: "blake2",
Usage: "Hash algorithm: blake2, md4",
},
},
},
{
Name: "delta",
Usage: "calculates the binary diff between old and new files",
ArgsUsage: "SIGNATURE NEWFILE DELTA",
Action: CommandDelta,
},
{
Name: "patch",
Usage: "uses the delta file and old file to produce the new file",
ArgsUsage: "BASIS DELTA NEWFILE",
Action: CommandPatch,
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}