aboutsummaryrefslogblamecommitdiffstats
path: root/lib/pama/switch.go
blob: 4d6b25f778d8f6b56526ce49dba9b2a7b9024dcf (plain) (tree)




























                                                                 
package pama

import (
	"fmt"
)

func (m PatchManager) SwitchProject(name string) error {
	c, err := m.CurrentProject()
	if err == nil {
		if c.Name == name {
			return nil
		}
	}
	names, err := m.store().Names()
	if err != nil {
		return storeErr(err)
	}
	found := false
	for _, n := range names {
		if n == name {
			found = true
			break
		}
	}
	if !found {
		return fmt.Errorf("Project '%s' not found", name)
	}
	return storeErr(m.store().SetCurrent(name))
}