55from rich .table import Table
66
77from codegen .configs .constants import ENV_FILENAME , GLOBAL_ENV_FILE
8- from codegen .configs .session_manager import session_manager
98from codegen .configs .user_config import UserConfig
9+ from codegen .shared .path import get_git_root_path
1010
1111
1212@click .group (name = "config" )
@@ -16,8 +16,7 @@ def config_command():
1616
1717
1818@config_command .command (name = "list" )
19- @click .option ("--global" , "is_global" , is_flag = True , help = "Lists the global configuration values" )
20- def list_command (is_global : bool ):
19+ def list_command ():
2120 """List current configuration values."""
2221
2322 def flatten_dict (data : dict , prefix : str = "" ) -> dict :
@@ -33,7 +32,7 @@ def flatten_dict(data: dict, prefix: str = "") -> dict:
3332 items [full_key ] = value
3433 return items
3534
36- config = _get_user_config (is_global )
35+ config = _get_user_config ()
3736 flat_config = flatten_dict (config .to_dict ())
3837 sorted_items = sorted (flat_config .items (), key = lambda x : x [0 ])
3938
@@ -82,10 +81,9 @@ def flatten_dict(data: dict, prefix: str = "") -> dict:
8281
8382@config_command .command (name = "get" )
8483@click .argument ("key" )
85- @click .option ("--global" , "is_global" , is_flag = True , help = "Get the global configuration value" )
86- def get_command (key : str , is_global : bool ):
84+ def get_command (key : str ):
8785 """Get a configuration value."""
88- config = _get_user_config (is_global )
86+ config = _get_user_config ()
8987 if not config .has_key (key ):
9088 rich .print (f"[red]Error: Configuration key '{ key } ' not found[/red]" )
9189 return
@@ -98,10 +96,9 @@ def get_command(key: str, is_global: bool):
9896@config_command .command (name = "set" )
9997@click .argument ("key" )
10098@click .argument ("value" )
101- @click .option ("--global" , "is_global" , is_flag = True , help = "Sets the global configuration value" )
102- def set_command (key : str , value : str , is_global : bool ):
99+ def set_command (key : str , value : str ):
103100 """Set a configuration value and write to .env"""
104- config = _get_user_config (is_global )
101+ config = _get_user_config ()
105102 if not config .has_key (key ):
106103 rich .print (f"[red]Error: Configuration key '{ key } ' not found[/red]" )
107104 return
@@ -118,10 +115,10 @@ def set_command(key: str, value: str, is_global: bool):
118115 rich .print (f"[green]Successfully set { key } =[magenta]{ value } [/magenta] and saved to { ENV_FILENAME } [/green]" )
119116
120117
121- def _get_user_config (is_global : bool ) -> UserConfig :
122- if is_global or ( active_session_path := session_manager . get_active_session ()) is None :
118+ def _get_user_config () -> UserConfig :
119+ if ( project_root := get_git_root_path ()) is None :
123120 env_filepath = GLOBAL_ENV_FILE
124121 else :
125- env_filepath = active_session_path / ENV_FILENAME
122+ env_filepath = project_root / ENV_FILENAME
126123
127124 return UserConfig (env_filepath )
0 commit comments