Compare commits
No commits in common. "325f77b9d4d665c6047476ba7e532d905597f425" and "85e333289b03d224da64441d26f902f95e127f9c" have entirely different histories.
325f77b9d4
...
85e333289b
2 changed files with 3 additions and 31 deletions
25
cmd/init.go
25
cmd/init.go
|
|
@ -1,10 +1,6 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import "github.com/spf13/cobra"
|
||||||
"git.towk2.me/towk/makeshift/pkg/service"
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var initCmd = &cobra.Command{
|
var initCmd = &cobra.Command{
|
||||||
Use: "init",
|
Use: "init",
|
||||||
|
|
@ -15,27 +11,10 @@ var initCmd = &cobra.Command{
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Short: "Initialize directory with default files",
|
Short: "Initialize directory with default files",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
|
||||||
rootPath, _ = cmd.Flags().GetString("root")
|
|
||||||
|
|
||||||
server *service.Service
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
// create the server root files and directories
|
|
||||||
err = server.Init()
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).
|
|
||||||
Str("root", rootPath).
|
|
||||||
Msg("failed to initialize server root")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Debug().
|
|
||||||
Str("root", rootPath).
|
|
||||||
Msg("initialize makeshift files at root path")
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(initCmd)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,14 +63,7 @@ var serveCmd = &cobra.Command{
|
||||||
|
|
||||||
// make the default directories and files if flag is passed
|
// make the default directories and files if flag is passed
|
||||||
if cmd.Flags().Changed("init") {
|
if cmd.Flags().Changed("init") {
|
||||||
err = server.Init()
|
server.Init()
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).
|
|
||||||
Str("host", parsed.Host).
|
|
||||||
Str("root", rootPath).
|
|
||||||
Msg("failed to initialize server root")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// serve and log why the server closed
|
// serve and log why the server closed
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue