Implements wrapper for search for apps

This commit is contained in:
Mikhail Klementev 2020-01-02 15:37:32 +00:00
parent 04b2cf63ce
commit 6c72b5de00
No known key found for this signature in database
GPG Key ID: BE44DA8C062D87DC
2 changed files with 22 additions and 0 deletions

View File

@ -40,6 +40,10 @@ You need to **relogin** if you install virt-manager (libvirt) first time.
$ go get -u code.dumpstack.io/tools/appvm $ go get -u code.dumpstack.io/tools/appvm
## Search for applications
$ appvm search chromium
## Generate new application ## Generate new application
$ nix-channel --list $ nix-channel --list

View File

@ -314,6 +314,19 @@ func autoBalloon(l *libvirt.Libvirt, memoryMin, adjustPercent uint64) {
table.Render() 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/" var configDir = os.Getenv("HOME") + "/.config/appvm/"
func main() { func main() {
@ -359,9 +372,14 @@ func main() {
generateBin := generateCommand.Arg("bin", "Binary").Default("").String() generateBin := generateCommand.Arg("bin", "Binary").Default("").String()
generateVMName := generateCommand.Flag("vm", "Use VM Name").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() { switch kingpin.Parse() {
case "list": case "list":
list(l) list(l)
case "search":
search(*searchName)
case "generate": case "generate":
generate(l, *generateName, *generateBin, *generateVMName) generate(l, *generateName, *generateBin, *generateVMName)
case "start": case "start":