Something went wrong. Try again.
Social cloud hosting
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566package cli
import ( "fmt" "os" "path/filepath" "text/tabwriter"
"github.com/spf13/cobra")
var runtimeCmd = &cobra.Command{ Use: "runtime", Short: "Manage runtime configurations",}
var runtimeListCmd = &cobra.Command{ Use: "list", Short: "List available runtimes", RunE: runRuntimeList,}
func init() { runtimeCmd.AddCommand(runtimeListCmd)}
func runRuntimeList(cmd *cobra.Command, args []string) error { dir := configDir() runtimesDir := filepath.Join(dir, "runtimes") imagesDir := filepath.Join(dir, "images")
entries, err := os.ReadDir(runtimesDir) if err != nil { if os.IsNotExist(err) { fmt.Println("No runtimes configured. Run 'at-rund init' first.") return nil } return err }
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) fmt.Fprintln(w, "RUNTIME\tCONFIG\tIMAGE\tSTATUS")
for _, e := range entries { if filepath.Ext(e.Name()) != ".nix" { continue }
name := e.Name()[:len(e.Name())-4] configPath := filepath.Join(runtimesDir, e.Name()) imagePath := filepath.Join(imagesDir, name)
status := "not built" if _, err := os.Stat(filepath.Join(imagePath, "rootfs.ext4")); err == nil { status = "ready" } else if _, err := os.Stat(imagePath); err == nil { status = "partial" }
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", name, configPath, imagePath, status) }
w.Flush() return nil}