mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-07 21:24:59 +00:00
Merge branch 'main' into register_settings
This commit is contained in:
commit
b6fa02044f
51 changed files with 1973 additions and 238 deletions
|
@ -7,30 +7,47 @@ import sys
|
|||
import configargparse
|
||||
|
||||
from aider import __version__, models
|
||||
from aider.args_formatter import MarkdownHelpFormatter, YamlHelpFormatter
|
||||
from aider.args_formatter import (
|
||||
DotEnvFormatter,
|
||||
MarkdownHelpFormatter,
|
||||
YamlHelpFormatter,
|
||||
)
|
||||
|
||||
from .dump import dump # noqa: F401
|
||||
|
||||
|
||||
def default_env_file(git_root):
|
||||
return os.path.join(git_root, ".env") if git_root else ".env"
|
||||
|
||||
|
||||
def get_preparser(git_root):
|
||||
parser = configargparse.ArgumentParser(add_help=False)
|
||||
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)",
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
def get_parser(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_",
|
||||
)
|
||||
group = parser.add_argument_group("Main")
|
||||
group.add_argument(
|
||||
"--vim",
|
||||
action="store_true",
|
||||
help="Use VI editing mode in the terminal (default: False)",
|
||||
default=False,
|
||||
"--llm-history-file",
|
||||
metavar="LLM_HISTORY_FILE",
|
||||
default=None,
|
||||
help="Log the conversation with the LLM to this file (for example, .aider.llm.history)",
|
||||
)
|
||||
group.add_argument(
|
||||
"files",
|
||||
metavar="FILE",
|
||||
nargs="*",
|
||||
help="files to edit with an LLM (optional)",
|
||||
"files", metavar="FILE", nargs="*", help="files to edit with an LLM (optional)"
|
||||
)
|
||||
group.add_argument(
|
||||
"--openai-api-key",
|
||||
|
@ -59,7 +76,7 @@ def get_parser(default_config_files, git_root):
|
|||
const=opus_model,
|
||||
help=f"Use {opus_model} model for the main chat",
|
||||
)
|
||||
sonnet_model = "claude-3-sonnet-20240229"
|
||||
sonnet_model = "claude-3-5-sonnet-20240620"
|
||||
group.add_argument(
|
||||
"--sonnet",
|
||||
action="store_const",
|
||||
|
@ -146,13 +163,18 @@ def get_parser(default_config_files, git_root):
|
|||
metavar="MODEL_SETTINGS_FILE",
|
||||
default=None,
|
||||
help="Specify a file with aider model settings for unknown models",
|
||||
)
|
||||
group.add_argument(
|
||||
"--model-metadata-file",
|
||||
metavar="MODEL_METADATA_FILE",
|
||||
default=None,
|
||||
help="Specify a file with context window and costs for unknown models",
|
||||
)
|
||||
group.add_argument(
|
||||
"--verify-ssl",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
default=True,
|
||||
help="Verify the SSL cert when connecting to models (default: True)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--edit-format",
|
||||
metavar="EDIT_FORMAT",
|
||||
|
@ -189,11 +211,12 @@ def get_parser(default_config_files, git_root):
|
|||
" max_chat_history_tokens."
|
||||
),
|
||||
)
|
||||
default_env_file = os.path.join(git_root, ".env") if git_root else ".env"
|
||||
# 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.
|
||||
group.add_argument(
|
||||
"--env-file",
|
||||
metavar="ENV_FILE",
|
||||
default=default_env_file,
|
||||
default=default_env_file(git_root),
|
||||
help="Specify the .env file to load (default: .env in git root)",
|
||||
)
|
||||
|
||||
|
@ -375,6 +398,12 @@ def get_parser(default_config_files, git_root):
|
|||
|
||||
##########
|
||||
group = parser.add_argument_group("Other Settings")
|
||||
group.add_argument(
|
||||
"--vim",
|
||||
action="store_true",
|
||||
help="Use VI editing mode in the terminal (default: False)",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--voice-language",
|
||||
metavar="VOICE_LANGUAGE",
|
||||
|
@ -500,11 +529,27 @@ def get_sample_yaml():
|
|||
return parser.format_help()
|
||||
|
||||
|
||||
def get_sample_dotenv():
|
||||
os.environ["COLUMNS"] = "120"
|
||||
sys.argv = ["aider"]
|
||||
parser = get_parser([], None)
|
||||
|
||||
# This instantiates all the action.env_var values
|
||||
parser.parse_known_args()
|
||||
|
||||
parser.formatter_class = DotEnvFormatter
|
||||
|
||||
return argparse.ArgumentParser.format_help(parser)
|
||||
return parser.format_help()
|
||||
|
||||
|
||||
def main():
|
||||
arg = sys.argv[1] if len(sys.argv[1:]) else None
|
||||
|
||||
if arg == "md":
|
||||
print(get_md_help())
|
||||
elif arg == "dotenv":
|
||||
print(get_sample_dotenv())
|
||||
else:
|
||||
print(get_sample_yaml())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue