From c9a8a534f230aa8cdb6799835f4e938361d73e7d Mon Sep 17 00:00:00 2001
From: Mikhail Klementev <jollheef@riseup.net>
Date: Thu, 12 Jul 2018 00:06:43 +0000
Subject: [PATCH] Add available vm's to 'appvm list'

---
 appvm.go | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/appvm.go b/appvm.go
index dffdddf..aa60293 100644
--- a/appvm.go
+++ b/appvm.go
@@ -9,6 +9,7 @@ package main
 
 import (
 	"fmt"
+	"io/ioutil"
 	"log"
 	"net"
 	"os"
@@ -98,10 +99,22 @@ func list(l *libvirt.Libvirt) {
 		log.Fatal(err)
 	}
 
-	// TODO list available to create VM's too
+	fmt.Println("Started VM:")
 	for _, d := range domains {
 		if d.Name[0:5] == "appvm" {
-			fmt.Println(d.Name[6:])
+			fmt.Println("\t", d.Name[6:])
+		}
+	}
+
+	fmt.Println("\nAvailable VM:")
+	files, err := ioutil.ReadDir(os.Getenv("GOPATH") + "/src/github.com/jollheef/appvm/nix")
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	for _, f := range files {
+		if f.Name() != "base.nix" && f.Name() != "local.nix" && f.Name() != "monitor.nix" {
+			fmt.Println("\t", f.Name()[0:len(f.Name())-4])
 		}
 	}
 }