File: main.go

package info (click to toggle)
golang-github-vbatts-tar-split 0.11.6-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, trixie
  • size: 744 kB
  • sloc: makefile: 2
file content (97 lines) | stat: -rw-r--r-- 2,005 bytes parent folder | download
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main

import (
	"os"

	"github.com/sirupsen/logrus"
	"github.com/urfave/cli"
)

var Version = "v0.11.3"

func main() {
	app := cli.NewApp()
	app.Name = "tar-split"
	app.Usage = "tar assembly and disassembly utility"
	app.Version = Version
	app.Author = "Vincent Batts"
	app.Email = "vbatts@hashbangbash.com"
	app.Action = cli.ShowAppHelp
	app.Before = func(c *cli.Context) error {
		logrus.SetOutput(os.Stderr)
		if c.Bool("debug") {
			logrus.SetLevel(logrus.DebugLevel)
		}
		return nil
	}
	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:  "debug, D",
			Usage: "debug output",
			// defaults to false
		},
	}
	app.Commands = []cli.Command{
		{
			Name:    "disasm",
			Aliases: []string{"d"},
			Usage:   "disassemble the input tar stream",
			Action:  CommandDisasm,
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "output",
					Value: "tar-data.json.gz",
					Usage: "output of disassembled tar stream",
				},
				cli.BoolFlag{
					Name:  "no-stdout",
					Usage: "do not throughput the stream to STDOUT",
				},
			},
		},
		{
			Name:    "asm",
			Aliases: []string{"a"},
			Usage:   "assemble tar stream",
			Action:  CommandAsm,
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "input",
					Value: "tar-data.json.gz",
					Usage: "input of disassembled tar stream",
				},
				cli.StringFlag{
					Name:  "output",
					Value: "-",
					Usage: "reassembled tar archive",
				},
				cli.StringFlag{
					Name:  "path",
					Value: "",
					Usage: "relative path of extracted tar",
				},
				cli.BoolFlag{
					Name:  "compress",
					Usage: "gzip compress the output",
					// defaults to false
				},
			},
		},
		{
			Name:   "checksize",
			Usage:  "displays size estimates for metadata storage of a Tar archive",
			Action: CommandChecksize,
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "work",
					Usage: "do not delete the working directory",
					// defaults to false
				},
			},
		},
	}

	if err := app.Run(os.Args); err != nil {
		logrus.Fatal(err)
	}
}