mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
Allow pre-parser to read the yaml, in case user wants to include env-file: option there
This commit is contained in:
parent
ecc21517ee
commit
95a4ed47e6
2 changed files with 19 additions and 3 deletions
|
@ -20,14 +20,30 @@ def default_env_file(git_root):
|
||||||
return os.path.join(git_root, ".env") if git_root else ".env"
|
return os.path.join(git_root, ".env") if git_root else ".env"
|
||||||
|
|
||||||
|
|
||||||
def get_preparser(git_root):
|
def get_preparser(default_config_files, git_root):
|
||||||
parser = configargparse.ArgumentParser(add_help=False)
|
parser = configargparse.ArgumentParser(
|
||||||
|
description="aider is GPT powered coding in your terminal",
|
||||||
|
add_config_file_help=True,
|
||||||
|
default_config_files=default_config_files,
|
||||||
|
config_file_parser_class=configargparse.YAMLConfigFileParser,
|
||||||
|
auto_env_var_prefix="AIDER_",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--env-file",
|
"--env-file",
|
||||||
metavar="ENV_FILE",
|
metavar="ENV_FILE",
|
||||||
default=default_env_file(git_root),
|
default=default_env_file(git_root),
|
||||||
help="Specify the .env file to load (default: .env in git root)",
|
help="Specify the .env file to load (default: .env in git root)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-c",
|
||||||
|
"--config",
|
||||||
|
is_config_file=True,
|
||||||
|
metavar="CONFIG_FILE",
|
||||||
|
help=(
|
||||||
|
"Specify the config file (default: search for .aider.conf.yml in git root, cwd"
|
||||||
|
" or home directory)"
|
||||||
|
),
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
default_config_files.append(Path.home() / conf_fname) # homedir
|
default_config_files.append(Path.home() / conf_fname) # homedir
|
||||||
default_config_files = list(map(str, default_config_files))
|
default_config_files = list(map(str, default_config_files))
|
||||||
|
|
||||||
preparser = get_preparser(git_root)
|
preparser = get_preparser(default_config_files, git_root)
|
||||||
pre_args, _ = preparser.parse_known_args(argv)
|
pre_args, _ = preparser.parse_known_args(argv)
|
||||||
|
|
||||||
# Load the .env file specified in the arguments
|
# Load the .env file specified in the arguments
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue