mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 04:35:00 +00:00
restored full --help
This commit is contained in:
parent
965c35870c
commit
29905a534a
2 changed files with 22 additions and 43 deletions
|
@ -20,42 +20,6 @@ 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(default_config_files, git_root):
|
|
||||||
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_",
|
|
||||||
)
|
|
||||||
|
|
||||||
add_env_file(parser, git_root)
|
|
||||||
add_config_option(parser)
|
|
||||||
return parser
|
|
||||||
|
|
||||||
|
|
||||||
def add_env_file(parser, git_root):
|
|
||||||
parser.add_argument(
|
|
||||||
"--env-file",
|
|
||||||
metavar="ENV_FILE",
|
|
||||||
default=default_env_file(git_root),
|
|
||||||
help="Specify the .env file to load (default: .env in git root)",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def add_config_option(parser):
|
|
||||||
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)"
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_parser(default_config_files, git_root):
|
def get_parser(default_config_files, git_root):
|
||||||
parser = configargparse.ArgumentParser(
|
parser = configargparse.ArgumentParser(
|
||||||
description="aider is GPT powered coding in your terminal",
|
description="aider is GPT powered coding in your terminal",
|
||||||
|
@ -239,7 +203,12 @@ def get_parser(default_config_files, git_root):
|
||||||
)
|
)
|
||||||
# This is a duplicate of the argument in the preparser and is a no-op by this time of
|
# This is a duplicate of the argument in the preparser and is a no-op by this time of
|
||||||
# argument parsing, but it's here so that the help is displayed as expected.
|
# argument parsing, but it's here so that the help is displayed as expected.
|
||||||
add_env_file(group, git_root)
|
group.add_argument(
|
||||||
|
"--env-file",
|
||||||
|
metavar="ENV_FILE",
|
||||||
|
default=default_env_file(git_root),
|
||||||
|
help="Specify the .env file to load (default: .env in git root)",
|
||||||
|
)
|
||||||
|
|
||||||
##########
|
##########
|
||||||
group = parser.add_argument_group("History Files")
|
group = parser.add_argument_group("History Files")
|
||||||
|
@ -513,7 +482,16 @@ def get_parser(default_config_files, git_root):
|
||||||
default="utf-8",
|
default="utf-8",
|
||||||
help="Specify the encoding for input and output (default: utf-8)",
|
help="Specify the encoding for input and output (default: utf-8)",
|
||||||
)
|
)
|
||||||
add_config_option(group)
|
group.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)"
|
||||||
|
),
|
||||||
|
)
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--gui",
|
"--gui",
|
||||||
"--browser",
|
"--browser",
|
||||||
|
|
|
@ -11,7 +11,7 @@ from prompt_toolkit.enums import EditingMode
|
||||||
from streamlit.web import cli
|
from streamlit.web import cli
|
||||||
|
|
||||||
from aider import __version__, models, utils
|
from aider import __version__, models, utils
|
||||||
from aider.args import get_parser, get_preparser
|
from aider.args import get_parser
|
||||||
from aider.coders import Coder
|
from aider.coders import Coder
|
||||||
from aider.commands import SwitchModel
|
from aider.commands import SwitchModel
|
||||||
from aider.io import InputOutput
|
from aider.io import InputOutput
|
||||||
|
@ -281,13 +281,14 @@ 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(default_config_files, git_root)
|
parser = get_parser(default_config_files, git_root)
|
||||||
pre_args, _ = preparser.parse_known_args(argv)
|
args, unknown = parser.parse_known_args(argv)
|
||||||
|
|
||||||
# Load the .env file specified in the arguments
|
# Load the .env file specified in the arguments
|
||||||
load_dotenv(pre_args.env_file)
|
if hasattr(args, "env_file"):
|
||||||
|
load_dotenv(args.env_file)
|
||||||
|
|
||||||
parser = get_parser(default_config_files, git_root)
|
# Parse again to include any arguments that might have been defined in .env
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
if not args.verify_ssl:
|
if not args.verify_ssl:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue