Skip to content

Commit 8856fe9

Browse files
CougarTaskerstepjam
authored andcommitted
fix: not saving single org
1 parent 9f192d1 commit 8856fe9

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

neuracore/core/cli/select_current_org.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ def select_current_org() -> Organization:
5555
raise ValueError()
5656

5757
organization = orgs[input_selection - 1]
58-
config_manager = get_config_manager()
59-
config_manager.config.current_org_id = organization.id
60-
config_manager.save_config()
6158
print(f"You have selected the organization: {organization.name}")
6259
return organization
6360
except ValueError:
@@ -81,7 +78,11 @@ def main() -> None:
8178
try:
8279
if not auth.is_authenticated:
8380
auth.login()
84-
select_current_org()
81+
organization = select_current_org()
82+
config_manager = get_config_manager()
83+
config_manager.config.current_org_id = organization.id
84+
config_manager.save_config()
85+
8586
except AuthenticationError:
8687
print("Failed to Authenticate, please try again")
8788
except (OrganizationError, InputError):

neuracore/core/config/get_current_org.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from neuracore.core.cli.input_lock import user_input_lock
44
from neuracore.core.cli.select_current_org import select_current_org
5-
from neuracore.core.config.config_manager import get_config
5+
from neuracore.core.config.config_manager import get_config_manager
66
from neuracore.core.exceptions import (
77
AuthenticationError,
88
ConfigError,
@@ -23,10 +23,14 @@ def get_current_org() -> str:
2323
ConfigError: If there is an error trying to get the config
2424
"""
2525
with user_input_lock:
26-
org_id = get_config().current_org_id
26+
config_manager = get_config_manager()
27+
org_id = config_manager.config.current_org_id
2728
if org_id:
2829
return org_id
2930
try:
30-
return select_current_org().id
31+
organization = select_current_org()
32+
config_manager.config.current_org_id = organization.id
33+
config_manager.save_config()
34+
return organization.id
3135
except (AuthenticationError, OrganizationError, InputError) as e:
3236
raise ConfigError(f"Failed to select organization: {e}")

0 commit comments

Comments
 (0)