From 172b7bf123c09bf1677f26d161cee19dfb6c86a4 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 30 Nov 2014 22:39:58 +0100 Subject: [PATCH] Move command init into cmd_* files --- cmd/khepri/cmd_backup.go | 4 ++++ cmd/khepri/cmd_cat.go | 4 ++++ cmd/khepri/cmd_key.go | 4 ++++ cmd/khepri/cmd_list.go | 4 ++++ cmd/khepri/cmd_ls.go | 4 ++++ cmd/khepri/cmd_restore.go | 4 ++++ cmd/khepri/cmd_snapshots.go | 4 ++++ cmd/khepri/main.go | 8 -------- 8 files changed, 28 insertions(+), 8 deletions(-) diff --git a/cmd/khepri/cmd_backup.go b/cmd/khepri/cmd_backup.go index 3a3c04271..964e8c439 100644 --- a/cmd/khepri/cmd_backup.go +++ b/cmd/khepri/cmd_backup.go @@ -12,6 +12,10 @@ import ( "golang.org/x/crypto/ssh/terminal" ) +func init() { + commands["backup"] = commandBackup +} + func format_bytes(c uint64) string { b := float64(c) diff --git a/cmd/khepri/cmd_cat.go b/cmd/khepri/cmd_cat.go index 47befd91a..7e892dddf 100644 --- a/cmd/khepri/cmd_cat.go +++ b/cmd/khepri/cmd_cat.go @@ -10,6 +10,10 @@ import ( "github.com/fd0/khepri/backend" ) +func init() { + commands["cat"] = commandCat +} + func commandCat(be backend.Server, key *khepri.Key, args []string) error { if len(args) != 2 { return errors.New("usage: cat [blob|tree|snapshot|key|lock] ID") diff --git a/cmd/khepri/cmd_key.go b/cmd/khepri/cmd_key.go index ad4814c2b..4aab50c4f 100644 --- a/cmd/khepri/cmd_key.go +++ b/cmd/khepri/cmd_key.go @@ -10,6 +10,10 @@ import ( "github.com/fd0/khepri/backend" ) +func init() { + commands["key"] = commandKey +} + func list_keys(be backend.Server, key *khepri.Key) error { tab := NewTable() tab.Header = fmt.Sprintf(" %-10s %-10s %-10s %s", "ID", "User", "Host", "Created") diff --git a/cmd/khepri/cmd_list.go b/cmd/khepri/cmd_list.go index f8fe4c132..6965cd022 100644 --- a/cmd/khepri/cmd_list.go +++ b/cmd/khepri/cmd_list.go @@ -8,6 +8,10 @@ import ( "github.com/fd0/khepri/backend" ) +func init() { + commands["list"] = commandList +} + func commandList(be backend.Server, key *khepri.Key, args []string) error { if len(args) != 1 { return errors.New("usage: list [data|trees|snapshots|keys|locks]") diff --git a/cmd/khepri/cmd_ls.go b/cmd/khepri/cmd_ls.go index 5ab98ace7..89b5adfa5 100644 --- a/cmd/khepri/cmd_ls.go +++ b/cmd/khepri/cmd_ls.go @@ -10,6 +10,10 @@ import ( "github.com/fd0/khepri/backend" ) +func init() { + commands["ls"] = commandLs +} + func print_node(prefix string, n *khepri.Node) string { switch n.Type { case "file": diff --git a/cmd/khepri/cmd_restore.go b/cmd/khepri/cmd_restore.go index de747c8e2..921fdcf70 100644 --- a/cmd/khepri/cmd_restore.go +++ b/cmd/khepri/cmd_restore.go @@ -9,6 +9,10 @@ import ( "github.com/fd0/khepri/backend" ) +func init() { + commands["restore"] = commandRestore +} + func commandRestore(be backend.Server, key *khepri.Key, args []string) error { if len(args) != 2 { return errors.New("usage: restore ID dir") diff --git a/cmd/khepri/cmd_snapshots.go b/cmd/khepri/cmd_snapshots.go index 5cec0e195..98db23021 100644 --- a/cmd/khepri/cmd_snapshots.go +++ b/cmd/khepri/cmd_snapshots.go @@ -72,6 +72,10 @@ func reltime(t time.Time) string { } } +func init() { + commands["snapshots"] = commandSnapshots +} + func commandSnapshots(be backend.Server, key *khepri.Key, args []string) error { if len(args) != 0 { return errors.New("usage: snapshots") diff --git a/cmd/khepri/main.go b/cmd/khepri/main.go index 237f1142c..a774f5205 100644 --- a/cmd/khepri/main.go +++ b/cmd/khepri/main.go @@ -126,14 +126,6 @@ func create(u string) (backend.Server, error) { } func init() { - commands["backup"] = commandBackup - commands["restore"] = commandRestore - commands["list"] = commandList - commands["snapshots"] = commandSnapshots - commands["cat"] = commandCat - commands["ls"] = commandLs - commands["key"] = commandKey - // set GOMAXPROCS to number of CPUs runtime.GOMAXPROCS(runtime.NumCPU()) }