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",
|
Use: "init",
|
||||||
Example: `
|
Example: `
|
||||||
# create default files and directories at specified root path
|
# create default files and directories at specified root path
|
||||||
|
# (must be set with positional argument)
|
||||||
makeshift init $MAKESHIFT_ROOT
|
makeshift init $MAKESHIFT_ROOT
|
||||||
`,
|
`,
|
||||||
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 (
|
var (
|
||||||
rootPath, _ = cmd.Flags().GetString("root")
|
|
||||||
|
|
||||||
server *service.Service
|
server *service.Service
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
// create the server root files and directories
|
// create the server root files and directories
|
||||||
|
server = service.New()
|
||||||
|
server.RootPath = args[0]
|
||||||
err = server.Init()
|
err = server.Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).
|
log.Error().Err(err).
|
||||||
Str("root", rootPath).
|
Str("root", server.RootPath).
|
||||||
Msg("failed to initialize server root")
|
Msg("failed to initialize server root")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Debug().
|
log.Debug().
|
||||||
Str("root", rootPath).
|
Str("root", server.RootPath).
|
||||||
Msg("initialize makeshift files at root path")
|
Msg("initialize makeshift files at root path")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue