mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 14:17:42 +00:00
Move command init into cmd_* files
This commit is contained in:
parent
bb8c52a974
commit
172b7bf123
@ -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)
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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]")
|
||||
|
@ -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":
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user