From d82b7df527b05db3ab2b7491ef9e47aea036d609 Mon Sep 17 00:00:00 2001
From: Leo <alingval@stud.ntnu.no>
Date: Thu, 29 Aug 2024 16:44:09 +0200
Subject: [PATCH] fix: make sure to write to profiles.json before reading

---
 gpm/cli.py     | 11 ++++++-----
 pyproject.toml |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/gpm/cli.py b/gpm/cli.py
index a91c68d..4b19805 100644
--- a/gpm/cli.py
+++ b/gpm/cli.py
@@ -19,7 +19,7 @@ Commands:
     current             Manage the current profile
 """
 
-__VERSION__ = "0.1.1"
+__VERSION__ = "0.1.2"
 __AUTHOR__ = "Leo <alingval@stud.ntnu.no>"
 
 from dataclasses import dataclass
@@ -152,6 +152,8 @@ class GPM:
         :param use_global_git_config: Whether to use the global git config or not, when initializing the class
         """
         self.profiles = []
+        
+        self.parser = setup()
         self._load() # Load profiles from file `data_file`
         self.use_global_git_config = use_global_git_config
 
@@ -482,8 +484,7 @@ class GPM:
         Run the Git Profile Manager
         :return: None
         """
-        parser = setup()
-        args = parser.parse_args()
+        args = self.parser.parse_args()
 
         if args.command == 'add':
             self.add(args.name, args.email, args.comment)
@@ -503,7 +504,7 @@ class GPM:
             elif args.current_command == 'remove':
                 self.current_remove()
             else:
-                parser.print_help()
+                self.parser.print_help()
         elif args.command == 'import':
             if getattr(args, 'global'):
                 self.use_global_git_config = True
@@ -511,7 +512,7 @@ class GPM:
         elif args.author:
             print(__AUTHOR__)
         else:
-            parser.print_help()
+            self.parser.print_help()
 
 
 def main():
diff --git a/pyproject.toml b/pyproject.toml
index 82f3eb5..36304dc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "gpm"
-version = "0.1.1"
+version = "0.1.2"
 description = "Git Profile Management CLI"
 authors = ["Leo <alingval@stud.ntnu.no>"]
 license = "MIT"
-- 
GitLab