aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-11-24 16:03:09 +0100
committerRobin Jarry <robin@jarry.cc>2023-12-30 15:42:09 +0100
commitcfcab6c5c883a08afa3a56c11e4f48d9725be2a0 (patch)
treeed774c1acbbfb481ebd1b2a30b69169d9f9804a6 /lib
parent8671d9dc483acf3c69022a8f2915166b83186559 (diff)
downloadaerc-cfcab6c5c883a08afa3a56c11e4f48d9725be2a0.tar.gz
patch/switch: add switch sub-cmd
Implement the :project switch command. Switch between different projects. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-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))
+}