func (c *ToolchainBundleCmd) Execute(args []string) error { log.Printf("Bundling toolchain %s...", c.Args.Toolchain) tmpDir, err := ioutil.TempDir("", path.Base(string(c.Args.Toolchain))+"toolchain-bundle") if err != nil { return err } log.Printf(" - output dir: %s", tmpDir) var variants []toolchain.Variant if c.Variant != "" { variants = append(variants, toolchain.ParseVariant(c.Variant)) } if c.Args.Dir == "" { info, err := toolchain.Lookup(string(c.Args.Toolchain)) if err != nil { return err } c.Args.Dir = info.Dir } bundles, err := toolchain.Bundle(c.Args.Dir, tmpDir, variants, c.DryRun, GlobalOpt.Verbose) if err != nil { return err } log.Println() log.Println("Bundles ready:", tmpDir) for _, b := range bundles { log.Println(" ", b) } return nil }
// getVENVBinPath returns toolchains Python virtualenv path. If toolchain is ran in // `docker` mode, it will return empty string because there is no virtualenv. func getVENVBinPath() (string, error) { if os.Getenv("IN_DOCKER_CONTAINER") == "" { tc, err := toolchain.Lookup("sourcegraph.com/sourcegraph/srclib-python") if err != nil { return "", err } return filepath.Join(tc.Dir, ".env", "bin"), nil } return "", nil }
func (t ToolName) Complete(match string) []flags.Completion { // Assume toolchain is the last arg. toolchainPath := os.Args[len(os.Args)-2] tc, err := toolchain.Lookup(toolchainPath) if err != nil { log.Println(err) return nil } c, err := tc.ReadConfig() if err != nil { log.Println(err) return nil } var comps []flags.Completion for _, tt := range c.Tools { if strings.HasPrefix(tt.Subcmd, match) { comps = append(comps, flags.Completion{Item: tt.Subcmd}) } } return comps }