zk/cmd/init.go

27 lines
499 B
Go
Raw Normal View History

2020-12-24 15:02:19 +00:00
package cmd
2020-12-28 12:16:11 +00:00
import (
"fmt"
"path/filepath"
2020-12-24 15:02:19 +00:00
2020-12-28 12:16:11 +00:00
"github.com/mickael-menu/zk/core/zk"
)
// Init creates a slip box in the given directory
2020-12-24 15:02:19 +00:00
type Init struct {
2020-12-28 12:16:11 +00:00
Directory string `arg optional type:"path" default:"." help:"Directory containing the slip box"`
2020-12-24 15:02:19 +00:00
}
func (cmd *Init) Run() error {
2020-12-28 12:16:11 +00:00
err := zk.Create(cmd.Directory)
if err == nil {
path, err := filepath.Abs(cmd.Directory)
if err != nil {
path = cmd.Directory
}
fmt.Printf("Initialized a slip box in %v\n", path)
}
return err
2020-12-24 15:02:19 +00:00
}