Skip to content
Snippets Groups Projects
Commit d82b7df5 authored by Leo's avatar Leo
Browse files

fix: make sure to write to profiles.json before reading

parent f9750937
Branches main
No related tags found
No related merge requests found
Pipeline #291680 passed
...@@ -19,7 +19,7 @@ Commands: ...@@ -19,7 +19,7 @@ Commands:
current Manage the current profile current Manage the current profile
""" """
__VERSION__ = "0.1.1" __VERSION__ = "0.1.2"
__AUTHOR__ = "Leo <alingval@stud.ntnu.no>" __AUTHOR__ = "Leo <alingval@stud.ntnu.no>"
from dataclasses import dataclass from dataclasses import dataclass
...@@ -152,6 +152,8 @@ class GPM: ...@@ -152,6 +152,8 @@ class GPM:
:param use_global_git_config: Whether to use the global git config or not, when initializing the class :param use_global_git_config: Whether to use the global git config or not, when initializing the class
""" """
self.profiles = [] self.profiles = []
self.parser = setup()
self._load() # Load profiles from file `data_file` self._load() # Load profiles from file `data_file`
self.use_global_git_config = use_global_git_config self.use_global_git_config = use_global_git_config
...@@ -482,8 +484,7 @@ class GPM: ...@@ -482,8 +484,7 @@ class GPM:
Run the Git Profile Manager Run the Git Profile Manager
:return: None :return: None
""" """
parser = setup() args = self.parser.parse_args()
args = parser.parse_args()
if args.command == 'add': if args.command == 'add':
self.add(args.name, args.email, args.comment) self.add(args.name, args.email, args.comment)
...@@ -503,7 +504,7 @@ class GPM: ...@@ -503,7 +504,7 @@ class GPM:
elif args.current_command == 'remove': elif args.current_command == 'remove':
self.current_remove() self.current_remove()
else: else:
parser.print_help() self.parser.print_help()
elif args.command == 'import': elif args.command == 'import':
if getattr(args, 'global'): if getattr(args, 'global'):
self.use_global_git_config = True self.use_global_git_config = True
...@@ -511,7 +512,7 @@ class GPM: ...@@ -511,7 +512,7 @@ class GPM:
elif args.author: elif args.author:
print(__AUTHOR__) print(__AUTHOR__)
else: else:
parser.print_help() self.parser.print_help()
def main(): def main():
......
[tool.poetry] [tool.poetry]
name = "gpm" name = "gpm"
version = "0.1.1" version = "0.1.2"
description = "Git Profile Management CLI" description = "Git Profile Management CLI"
authors = ["Leo <alingval@stud.ntnu.no>"] authors = ["Leo <alingval@stud.ntnu.no>"]
license = "MIT" license = "MIT"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment