fix: panic with using init cmd

This commit is contained in:
David Allen 2025-08-29 22:39:49 -06:00
parent 325f77b9d4
commit 94887aae9e
Signed by: towk
GPG key ID: 0430CDBE22619155

View file

@ -10,28 +10,29 @@ var initCmd = &cobra.Command{
Use: "init",
Example: `
# create default files and directories at specified root path
# (must be set with positional argument)
makeshift init $MAKESHIFT_ROOT
`,
Args: cobra.ExactArgs(1),
Short: "Initialize directory with default files",
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
server = service.New()
server.RootPath = args[0]
err = server.Init()
if err != nil {
log.Error().Err(err).
Str("root", rootPath).
Str("root", server.RootPath).
Msg("failed to initialize server root")
return
}
log.Debug().
Str("root", rootPath).
Str("root", server.RootPath).
Msg("initialize makeshift files at root path")
},
}