File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,20 +17,7 @@ var Analyse = cli.Command{
1717 UsageText : "Display statistical information about the backup file." ,
1818 Aliases : []string {"analyze" },
1919 CustomHelpTemplate : SubcommandHelp ,
20- Flags : []cli.Flag {
21- cli.StringFlag {
22- Name : "log, l" ,
23- Usage : "write logging output to `FILE`" ,
24- },
25- cli.StringFlag {
26- Name : "password, p" ,
27- Usage : "use `PASS` as password for backup file" ,
28- },
29- cli.StringFlag {
30- Name : "pwdfile, P" ,
31- Usage : "read password from `FILE`" ,
32- },
33- },
20+ Flags : coreFlags ,
3421 Action : func (c * cli.Context ) error {
3522 bf , err := setup (c )
3623 if err != nil {
Original file line number Diff line number Diff line change @@ -18,24 +18,12 @@ var Extract = cli.Command{
1818 Usage : "Retrieve attachments from the backup" ,
1919 UsageText : "Decrypt files embedded in the backup." ,
2020 CustomHelpTemplate : SubcommandHelp ,
21- Flags : []cli.Flag {
22- cli.StringFlag {
23- Name : "log, l" ,
24- Usage : "write logging output to `FILE`" ,
25- },
26- cli.StringFlag {
27- Name : "password, p" ,
28- Usage : "use `PASS` as password for backup file" ,
29- },
30- cli.StringFlag {
31- Name : "pwdfile, P" ,
32- Usage : "read password from `FILE`" ,
33- },
21+ Flags : append ([]cli.Flag {
3422 cli.StringFlag {
3523 Name : "outdir, o" ,
3624 Usage : "output attachments to `DIRECTORY`" ,
3725 },
38- },
26+ }, coreFlags ... ),
3927 Action : func (c * cli.Context ) error {
4028 bf , err := setup (c )
4129 if err != nil {
@@ -77,7 +65,7 @@ func ExtractAttachments(bf *types.BackupFile) error {
7765 }
7866
7967 if a := f .GetAttachment (); a != nil {
80- log .Printf ("found attachment binary %v\n \n " , * a .AttachmentId )
68+ log .Printf ("found attachment binary %v\n " , * a .AttachmentId )
8169 id := * a .AttachmentId
8270
8371 mime , hasMime := aEncs [id ]
Original file line number Diff line number Diff line change @@ -20,34 +20,22 @@ var Format = cli.Command{
2020 Usage : "Read and format the backup file" ,
2121 UsageText : "Parse and transform the backup file into other formats.\n Valid formats include: CSV, XML." ,
2222 CustomHelpTemplate : SubcommandHelp ,
23- Flags : []cli.Flag {
23+ Flags : append ( []cli.Flag {
2424 cli.StringFlag {
2525 Name : "format, f" ,
2626 Usage : "output the backup as `FORMAT`" ,
2727 Value : "xml" ,
2828 },
29- cli.StringFlag {
30- Name : "log, l" ,
31- Usage : "write logging output to `FILE`" ,
32- },
3329 cli.StringFlag {
3430 Name : "message, m" ,
3531 Usage : "format `TYPE` messages" ,
3632 Value : "sms" ,
3733 },
38- cli.StringFlag {
39- Name : "password, p" ,
40- Usage : "use `PASS` as password for backup file" ,
41- },
42- cli.StringFlag {
43- Name : "pwdfile, P" ,
44- Usage : "read password from `FILE`" ,
45- },
4634 cli.StringFlag {
4735 Name : "output, o" ,
4836 Usage : "write decrypted format to `FILE`" ,
4937 },
50- },
38+ }, coreFlags ... ),
5139 Action : func (c * cli.Context ) error {
5240 bf , err := setup (c )
5341 if err != nil {
Original file line number Diff line number Diff line change 44 "bufio"
55 "fmt"
66 "io/ioutil"
7+ "log"
78 "os"
89
910 "github.com/pkg/errors"
@@ -32,7 +33,28 @@ const SubcommandHelp = `Usage: {{.HelpName}} [OPTION...] BACKUPFILE
3233 {{end}}{{end}}
3334`
3435
36+ var coreFlags = []cli.Flag {
37+ cli.StringFlag {
38+ Name : "password, p" ,
39+ Usage : "use `PASS` as password for backup file" ,
40+ },
41+ cli.StringFlag {
42+ Name : "pwdfile, P" ,
43+ Usage : "read password from `FILE`" ,
44+ },
45+ cli.BoolFlag {
46+ Name : "verbose, v" ,
47+ Usage : "enable verbose logging output" ,
48+ },
49+ }
50+
3551func setup (c * cli.Context ) (* types.BackupFile , error ) {
52+ // -- Enable logging
53+
54+ if ! c .Bool ("verbose" ) {
55+ log .SetOutput (ioutil .Discard )
56+ }
57+
3658 // -- Verify
3759
3860 if c .Args ().Get (0 ) == "" {
You can’t perform that action at this time.
0 commit comments