1
0

Implements dry run for image edit

This commit is contained in:
dump_stack() 2023-04-07 21:30:03 +00:00
parent bb319a9ff6
commit 4a3d739b85
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -13,6 +13,7 @@ import (
"os"
"os/exec"
"os/user"
"strings"
"time"
"code.dumpstack.io/tools/out-of-tree/config"
@ -46,7 +47,8 @@ func (cmd *ImageListCmd) Run(g *Globals) (err error) {
}
type ImageEditCmd struct {
Name string `help:"image name" required:""`
Name string `help:"image name" required:""`
DryRun bool `help:"do nothing, just print commands"`
}
func (cmd *ImageEditCmd) Run(g *Globals) (err error) {
@ -86,6 +88,22 @@ func (cmd *ImageEditCmd) Run(g *Globals) (err error) {
q.Mutable = true
if cmd.DryRun {
s := q.Executable()
for _, arg := range q.Args() {
if strings.Contains(arg, " ") ||
strings.Contains(arg, ",") {
s += fmt.Sprintf(` "%s"`, arg)
} else {
s += fmt.Sprintf(" %s", arg)
}
}
fmt.Println(s)
fmt.Println(q.GetSSHCommand())
return
}
err = q.Start()
if err != nil {
fmt.Println("Qemu start error:", err)