From 6c72b5de005c9f4795348d7e17c563fccf0a964c Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Thu, 2 Jan 2020 15:37:32 +0000 Subject: [PATCH] Implements wrapper for search for apps --- README.md | 4 ++++ appvm.go | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 53339cb..b5b97bc 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,10 @@ You need to **relogin** if you install virt-manager (libvirt) first time. $ go get -u code.dumpstack.io/tools/appvm +## Search for applications + + $ appvm search chromium + ## Generate new application $ nix-channel --list diff --git a/appvm.go b/appvm.go index fdf9fe0..856ebc3 100644 --- a/appvm.go +++ b/appvm.go @@ -314,6 +314,19 @@ func autoBalloon(l *libvirt.Libvirt, memoryMin, adjustPercent uint64) { table.Render() } +func search(name string) { + command := exec.Command("nix", "search", name) + bytes, err := command.Output() + if err != nil { + return + } + + for _, line := range strings.Split(string(bytes), "\n") { + fmt.Println(line) + } + return +} + var configDir = os.Getenv("HOME") + "/.config/appvm/" func main() { @@ -359,9 +372,14 @@ func main() { generateBin := generateCommand.Arg("bin", "Binary").Default("").String() generateVMName := generateCommand.Flag("vm", "Use VM Name").Default("").String() + searchCommand := kingpin.Command("search", "Search for application") + searchName := searchCommand.Arg("name", "Application name").Required().String() + switch kingpin.Parse() { case "list": list(l) + case "search": + search(*searchName) case "generate": generate(l, *generateName, *generateBin, *generateVMName) case "start":