func findOriginalTask(state *core.BuildState, target core.BuildLabel) { if target.IsAllSubpackages() { for pkg := range utils.FindAllSubpackages(state.Config, target.PackageName, "") { state.AddOriginalTarget(core.NewBuildLabel(pkg, "all")) } } else { state.AddOriginalTarget(target) } }
func queryCompletionPackages(config *core.Configuration, query, repoRoot string) { root := path.Join(repoRoot, query) origRoot := root if !core.PathExists(root) { root = path.Dir(root) } packages := []string{} for pkg := range utils.FindAllSubpackages(config, root, origRoot) { if strings.HasPrefix(pkg, origRoot) { packages = append(packages, pkg[len(repoRoot):]) } } // If there's only one package, we know it has to be that, but we don't present // only one option otherwise bash completion will assume it's that. if len(packages) == 1 { fmt.Printf("/%s:\n", packages[0]) fmt.Printf("/%s:all\n", packages[0]) } else { for _, pkg := range packages { fmt.Printf("/%s\n", pkg) } } os.Exit(0) // Don't need to run a full-blown parse, get out now. }