Extract mod init code to separate function
@@ -28,20 +28,31 @@ func (m *modCmd) Configure(app *kingpin.Application) *kingpin.CmdClause {
func (m *modCmd) Execute(args ExecuteArgs) error {
if m.subcommand == "init" {
+ err := syslModInit(args)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func syslModInit(args ExecuteArgs) error {
// ignore folder creation error
_err := args.Filesystem.Mkdir(syslRootMarker, 0755)
if _err != nil {
args.Logger.Warn(_err.Error())
}
+
err := os.Chdir(syslRootMarker)
if err != nil {
return err
}
+
out, err := exec.Command("go", "mod", "init", syslModuleName).CombinedOutput()
if err != nil {
return err
}
+
args.Logger.Debug(out)
- }
return nil
}
