Update config path resolution logic
- Modify `resolve_config_path` to check for `.json` files. - First check in the current directory. - Then check in `.ait` directory in the user's home directory. - Return filename even if non-existent for later failure handling.
This commit is contained in:
22
ait.py
22
ait.py
@@ -22,7 +22,8 @@ def load_config(config_path):
|
|||||||
def resolve_config_path(config_input):
|
def resolve_config_path(config_input):
|
||||||
"""
|
"""
|
||||||
Resolves the configuration file path. If a single word is provided,
|
Resolves the configuration file path. If a single word is provided,
|
||||||
it looks for a file named 'ait.WORD.config' in the current directory.
|
it looks for a file named 'ait.WORD.config.json' in the current directory first,
|
||||||
|
then in a '.ait' directory in the user's home directory.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
- config_input (str): The input provided via the command-line argument.
|
- config_input (str): The input provided via the command-line argument.
|
||||||
@@ -30,9 +31,24 @@ def resolve_config_path(config_input):
|
|||||||
Returns:
|
Returns:
|
||||||
- str: The resolved path to the configuration file.
|
- str: The resolved path to the configuration file.
|
||||||
"""
|
"""
|
||||||
|
# If it's a keyword, construct the potential filenames
|
||||||
if not config_input.endswith(".json"):
|
if not config_input.endswith(".json"):
|
||||||
config_input = f"ait.{config_input}.config.json"
|
config_filename = f"ait.{config_input}.config.json"
|
||||||
return config_input
|
else:
|
||||||
|
config_filename = config_input
|
||||||
|
|
||||||
|
# Check in the current directory
|
||||||
|
if os.path.exists(config_filename):
|
||||||
|
return config_filename
|
||||||
|
|
||||||
|
# Check in the user's home directory under .ait/
|
||||||
|
home_directory = os.path.expanduser("~")
|
||||||
|
user_config_path = os.path.join(home_directory, ".ait", config_filename)
|
||||||
|
if os.path.exists(user_config_path):
|
||||||
|
return user_config_path
|
||||||
|
|
||||||
|
# If nothing found, return the filename (it will fail later if non-existent)
|
||||||
|
return config_filename
|
||||||
|
|
||||||
def run_git_commands(diff_expression, log_expression):
|
def run_git_commands(diff_expression, log_expression):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user