Created
January 13, 2020 15:23
-
-
Save ksoda/8794724abaeb32a7a1051daa041c34b9 to your computer and use it in GitHub Desktop.
Install a specific version of a package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//usr/bin/env go run "$0" "$@"; exit "$?" | |
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/codeskyblue/go-sh" | |
) | |
func main() { | |
plugin := asdfWithSelect("plugin-list") | |
version := asdfWithSelect("list-all", plugin) | |
sh.Command("asdf", "install", plugin, version).Run() | |
} | |
func asdfWithSelect(args ...string) string { | |
lis := make([]interface{}, 0) | |
for _, v := range args { | |
lis = append(lis, v) | |
} | |
out, err := sh.Command("asdf", lis...).Command("fzf").Output() | |
if err != nil { | |
fmt.Println(err.Error()) | |
os.Exit(1) | |
} | |
return string(out) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment