Skip to content

Commit

Permalink
output entrypoint and command in exec form ["aaa", "bbb"]
Browse files Browse the repository at this point in the history
  • Loading branch information
soulware committed Jun 6, 2023
1 parent f8eb61f commit 80286fe
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions internal/command/machine/status.go
Expand Up @@ -4,9 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"time"

"github.com/alecthomas/chroma/quick"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/internal/command"
Expand Down Expand Up @@ -59,6 +57,24 @@ func runMachineStatus(ctx context.Context) (err error) {
fmt.Fprintf(io.Out, "Instance ID: %s\n", machine.InstanceID)
fmt.Fprintf(io.Out, "State: %s\n\n", machine.State)

entrypoint := func() string {
if len(machine.Config.Init.Entrypoint) > 0 {
bytes, _ := json.Marshal(machine.Config.Init.Entrypoint)
return string(bytes)
} else {
return ""
}
}()

cmd := func() string {
if len(machine.Config.Init.Cmd) > 0 {
bytes, _ := json.Marshal(machine.Config.Init.Cmd)
return string(bytes)
} else {
return ""
}
}()

obj := [][]string{
{
machine.ID,
Expand All @@ -74,8 +90,8 @@ func runMachineStatus(ctx context.Context) (err error) {
fmt.Sprint(machine.Config.Guest.MemoryMB),
machine.CreatedAt,
machine.UpdatedAt,
strings.Join(machine.Config.Init.Entrypoint, " "),
strings.Join(machine.Config.Init.Cmd, " "),
string(entrypoint),
string(cmd),
},
}

Expand Down

0 comments on commit 80286fe

Please sign in to comment.