aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-10-06 11:25:10 +0200
committern-peugnet <n.peugnet@free.fr>2021-10-06 11:25:10 +0200
commit9b9710511b0dbe51ac030ef908f9468103b0bd0a (patch)
treea6c399d75a6dd266cc7765ba7e28a1e2fc6e4744 /main.go
parent6897c0ae70892e40fd7603e4d00662038c01a82d (diff)
downloaddna-backup-9b9710511b0dbe51ac030ef908f9468103b0bd0a.tar.gz
dna-backup-9b9710511b0dbe51ac030ef908f9468103b0bd0a.zip
refactor main and logger
Diffstat (limited to 'main.go')
-rw-r--r--main.go32
1 files changed, 18 insertions, 14 deletions
diff --git a/main.go b/main.go
index cf208c9..51cfac2 100644
--- a/main.go
+++ b/main.go
@@ -10,30 +10,34 @@ import (
type command struct {
Flag *flag.FlagSet
+ Run func([]string) error
Usage string
Help string
- Run func([]string) error
}
const (
- name = "dna-backup"
- baseUsage = "<command> [<options>] [--] <args>"
- commitUsage = "[<options>] [--] <source> <dest>"
- commitHelp = "Create a new version of folder <source> into repo <dest>"
- restoreUsage = "[<options>] [--] <source> <dest>"
- restoreHelp = "Restore the last version from repo <source> into folder <dest>"
+ name = "dna-backup"
+ baseUsage = "<command> [<options>] [--] <args>"
)
var (
- logLevel int
- commitCmd = flag.NewFlagSet("commit", flag.ExitOnError)
- restoreCmd = flag.NewFlagSet("restore", flag.ExitOnError)
- subcommands = map[string]command{
- commitCmd.Name(): {commitCmd, commitUsage, commitHelp, commitMain},
- restoreCmd.Name(): {restoreCmd, restoreUsage, restoreHelp, restoreMain},
- }
+ logLevel int
+ format string
)
+var commit = command{flag.NewFlagSet("commit", flag.ExitOnError), commitMain,
+ "[<options>] [--] <source> <dest>",
+ "Create a new version of folder <source> into repo <dest>",
+}
+var restore = command{flag.NewFlagSet("restore", flag.ExitOnError), restoreMain,
+ "[<options>] [--] <source> <dest>",
+ "Restore the last version from repo <source> into folder <dest>",
+}
+var subcommands = map[string]command{
+ commit.Flag.Name(): commit,
+ restore.Flag.Name(): restore,
+}
+
func init() {
// init default help message
flag.Usage = func() {