aboutsummaryrefslogtreecommitdiffstats
path: root/lib/pama
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pama')
-rw-r--r--lib/pama/switch.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/pama/switch.go b/lib/pama/switch.go
new file mode 100644
index 00000000..4d6b25f7
--- /dev/null
+++ b/lib/pama/switch.go
@@ -0,0 +1,29 @@
+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))
+}