fix: panic with using init cmd
This commit is contained in:
parent
325f77b9d4
commit
94887aae9e
1 changed files with 5 additions and 4 deletions
|
|
@ -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")
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue