45 lines
673 B
Go
45 lines
673 B
Go
package cmd
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"upod/internal/container"
|
|
"upod/internal/log"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
runCommand = &cobra.Command{
|
|
Use: "run",
|
|
Short: "upod run [OPTIONS] IMAGE [COMMAND] [ARG...]",
|
|
RunE: func(ctx *cobra.Command, args []string) error {
|
|
var (
|
|
err error
|
|
)
|
|
|
|
log.Debug("runCommand: args=%v", args)
|
|
|
|
if len(args) == 0 {
|
|
return errors.New("upod run requires at least 1 argument")
|
|
}
|
|
|
|
cmd := container.NewParentProcess(true, args[0])
|
|
|
|
if err = cmd.Start(); err != nil {
|
|
return err
|
|
}
|
|
|
|
cmd.Wait()
|
|
|
|
os.Exit(0)
|
|
|
|
return nil
|
|
},
|
|
}
|
|
)
|
|
|
|
func initRunCommand() {
|
|
rootCommand.AddCommand(runCommand)
|
|
}
|