mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 04:35:00 +00:00
refactor: reorganize command line arguments and improve help messages
This commit is contained in:
parent
7ae9569816
commit
20042334ff
10 changed files with 775 additions and 693 deletions
254
aider/args.py
254
aider/args.py
|
@ -28,7 +28,7 @@ def get_parser(default_config_files, git_root):
|
|||
config_file_parser_class=configargparse.YAMLConfigFileParser,
|
||||
auto_env_var_prefix="AIDER_",
|
||||
)
|
||||
group = parser.add_argument_group("Main")
|
||||
group = parser.add_argument_group("Main model")
|
||||
group.add_argument(
|
||||
"files", metavar="FILE", nargs="*", help="files to edit with an LLM (optional)"
|
||||
)
|
||||
|
@ -135,7 +135,7 @@ def get_parser(default_config_files, git_root):
|
|||
group = parser.add_argument_group("API Keys and settings")
|
||||
group.add_argument(
|
||||
"--openai-api-key",
|
||||
help="(deprecated, use --set-env OPENAI_API_KEY=<value>)",
|
||||
help="Specify the OpenAI API key",
|
||||
)
|
||||
group.add_argument(
|
||||
"--anthropic-api-key",
|
||||
|
@ -143,7 +143,7 @@ def get_parser(default_config_files, git_root):
|
|||
)
|
||||
group.add_argument(
|
||||
"--openai-api-base",
|
||||
help="(deprecated, use --set-env OPENAI_API_BASE=<value>)",
|
||||
help="Specify the api base url",
|
||||
)
|
||||
group.add_argument(
|
||||
"--openai-api-type",
|
||||
|
@ -165,17 +165,20 @@ def get_parser(default_config_files, git_root):
|
|||
"--set-env",
|
||||
action="append",
|
||||
metavar="ENV_VAR_NAME=value",
|
||||
help="Set an environment variable (can be used multiple times)",
|
||||
help="Set an environment variable (to control API settings, can be used multiple times)",
|
||||
default=[],
|
||||
)
|
||||
group.add_argument(
|
||||
"--api-key",
|
||||
action="append",
|
||||
metavar="PROVIDER=KEY",
|
||||
help="Set an API key for a provider (eg: --api-key anthropic=sk-123)",
|
||||
help=(
|
||||
"Set an API key for a provider (eg: --api-key provider=<key> sets"
|
||||
" PROVIDER_API_KEY=<key>)"
|
||||
),
|
||||
default=[],
|
||||
)
|
||||
group = parser.add_argument_group("Model Settings")
|
||||
group = parser.add_argument_group("Model settings")
|
||||
group.add_argument(
|
||||
"--list-models",
|
||||
"--models",
|
||||
|
@ -262,17 +265,9 @@ def get_parser(default_config_files, git_root):
|
|||
" If unspecified, defaults to the model's max_chat_history_tokens."
|
||||
),
|
||||
)
|
||||
# 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(git_root),
|
||||
help="Specify the .env file to load (default: .env in git root)",
|
||||
)
|
||||
|
||||
##########
|
||||
group = parser.add_argument_group("Cache Settings")
|
||||
group = parser.add_argument_group("Cache settings")
|
||||
group.add_argument(
|
||||
"--cache-prompts",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
|
@ -287,7 +282,7 @@ def get_parser(default_config_files, git_root):
|
|||
)
|
||||
|
||||
##########
|
||||
group = parser.add_argument_group("Repomap Settings")
|
||||
group = parser.add_argument_group("Repomap settings")
|
||||
group.add_argument(
|
||||
"--map-tokens",
|
||||
type=int,
|
||||
|
@ -344,7 +339,7 @@ def get_parser(default_config_files, git_root):
|
|||
)
|
||||
|
||||
##########
|
||||
group = parser.add_argument_group("Output Settings")
|
||||
group = parser.add_argument_group("Output settings")
|
||||
group.add_argument(
|
||||
"--dark-mode",
|
||||
action="store_true",
|
||||
|
@ -443,7 +438,7 @@ def get_parser(default_config_files, git_root):
|
|||
)
|
||||
|
||||
##########
|
||||
group = parser.add_argument_group("Git Settings")
|
||||
group = parser.add_argument_group("Git settings")
|
||||
group.add_argument(
|
||||
"--git",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
|
@ -536,12 +531,6 @@ def get_parser(default_config_files, git_root):
|
|||
default=False,
|
||||
help="Enable/disable watching files for ai coding comments (default: False)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--copy-paste",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
default=False,
|
||||
help="Enable automatic copy/paste of chat between aider and web UI (default: False)",
|
||||
)
|
||||
group = parser.add_argument_group("Fixing and committing")
|
||||
group.add_argument(
|
||||
"--lint",
|
||||
|
@ -602,37 +591,8 @@ def get_parser(default_config_files, git_root):
|
|||
default=False,
|
||||
)
|
||||
|
||||
group = parser.add_argument_group("Other Settings")
|
||||
group.add_argument(
|
||||
"--file",
|
||||
action="append",
|
||||
metavar="FILE",
|
||||
help="specify a file to edit (can be used multiple times)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--read",
|
||||
action="append",
|
||||
metavar="FILE",
|
||||
help="specify a read-only file (can be used multiple times)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--vim",
|
||||
action="store_true",
|
||||
help="Use VI editing mode in the terminal (default: False)",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--chat-language",
|
||||
metavar="CHAT_LANGUAGE",
|
||||
default=None,
|
||||
help="Specify the language to use in the chat (default: None, uses system settings)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--version",
|
||||
action="version",
|
||||
version=f"%(prog)s {__version__}",
|
||||
help="Show the version number and exit",
|
||||
)
|
||||
#########
|
||||
group = parser.add_argument_group("Upgrading")
|
||||
group.add_argument(
|
||||
"--just-check-update",
|
||||
action="store_true",
|
||||
|
@ -665,47 +625,14 @@ def get_parser(default_config_files, git_root):
|
|||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--apply",
|
||||
metavar="FILE",
|
||||
help="Apply the changes from the given file instead of running the chat (debug)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--apply-clipboard-edits",
|
||||
action="store_true",
|
||||
help="Apply clipboard contents as edits using the main model's editor format",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--yes-always",
|
||||
action="store_true",
|
||||
help="Always say yes to every confirmation",
|
||||
default=None,
|
||||
)
|
||||
group.add_argument(
|
||||
"-v",
|
||||
"--verbose",
|
||||
action="store_true",
|
||||
help="Enable verbose output",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--show-repo-map",
|
||||
action="store_true",
|
||||
help="Print the repo map and exit (debug)",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--show-prompts",
|
||||
action="store_true",
|
||||
help="Print the system prompts and exit (debug)",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--exit",
|
||||
action="store_true",
|
||||
help="Do all startup activities then exit before accepting user input (debug)",
|
||||
default=False,
|
||||
"--version",
|
||||
action="version",
|
||||
version=f"%(prog)s {__version__}",
|
||||
help="Show the version number and exit",
|
||||
)
|
||||
|
||||
##########
|
||||
group = parser.add_argument_group("Modes")
|
||||
group.add_argument(
|
||||
"--message",
|
||||
"--msg",
|
||||
|
@ -724,6 +651,110 @@ def get_parser(default_config_files, git_root):
|
|||
" (disables chat mode)"
|
||||
),
|
||||
)
|
||||
group.add_argument(
|
||||
"--gui",
|
||||
"--browser",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
help="Run aider in your browser (default: False)",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--copy-paste",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
default=False,
|
||||
help="Enable automatic copy/paste of chat between aider and web UI (default: False)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--apply",
|
||||
metavar="FILE",
|
||||
help="Apply the changes from the given file instead of running the chat (debug)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--apply-clipboard-edits",
|
||||
action="store_true",
|
||||
help="Apply clipboard contents as edits using the main model's editor format",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--exit",
|
||||
action="store_true",
|
||||
help="Do all startup activities then exit before accepting user input (debug)",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--show-repo-map",
|
||||
action="store_true",
|
||||
help="Print the repo map and exit (debug)",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--show-prompts",
|
||||
action="store_true",
|
||||
help="Print the system prompts and exit (debug)",
|
||||
default=False,
|
||||
)
|
||||
|
||||
##########
|
||||
group = parser.add_argument_group("Voice settings")
|
||||
group.add_argument(
|
||||
"--voice-format",
|
||||
metavar="VOICE_FORMAT",
|
||||
default="wav",
|
||||
choices=["wav", "mp3", "webm"],
|
||||
help="Audio format for voice recording (default: wav). webm and mp3 require ffmpeg",
|
||||
)
|
||||
group.add_argument(
|
||||
"--voice-language",
|
||||
metavar="VOICE_LANGUAGE",
|
||||
default="en",
|
||||
help="Specify the language for voice using ISO 639-1 code (default: auto)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--voice-input-device",
|
||||
metavar="VOICE_INPUT_DEVICE",
|
||||
default=None,
|
||||
help="Specify the input device name for voice recording",
|
||||
)
|
||||
|
||||
######
|
||||
group = parser.add_argument_group("Other settings")
|
||||
group.add_argument(
|
||||
"--file",
|
||||
action="append",
|
||||
metavar="FILE",
|
||||
help="specify a file to edit (can be used multiple times)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--read",
|
||||
action="append",
|
||||
metavar="FILE",
|
||||
help="specify a read-only file (can be used multiple times)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--vim",
|
||||
action="store_true",
|
||||
help="Use VI editing mode in the terminal (default: False)",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--chat-language",
|
||||
metavar="CHAT_LANGUAGE",
|
||||
default=None,
|
||||
help="Specify the language to use in the chat (default: None, uses system settings)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--yes-always",
|
||||
action="store_true",
|
||||
help="Always say yes to every confirmation",
|
||||
default=None,
|
||||
)
|
||||
group.add_argument(
|
||||
"-v",
|
||||
"--verbose",
|
||||
action="store_true",
|
||||
help="Enable verbose output",
|
||||
default=False,
|
||||
)
|
||||
group.add_argument(
|
||||
"--load",
|
||||
metavar="LOAD_FILE",
|
||||
|
@ -744,12 +775,13 @@ def get_parser(default_config_files, git_root):
|
|||
" or home directory)"
|
||||
),
|
||||
)
|
||||
# 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(
|
||||
"--gui",
|
||||
"--browser",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
help="Run aider in your browser (default: False)",
|
||||
default=False,
|
||||
"--env-file",
|
||||
metavar="ENV_FILE",
|
||||
default=default_env_file(git_root),
|
||||
help="Specify the .env file to load (default: .env in git root)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--suggest-shell-commands",
|
||||
|
@ -774,28 +806,6 @@ def get_parser(default_config_files, git_root):
|
|||
help="Specify which editor to use for the /editor command",
|
||||
)
|
||||
|
||||
##########
|
||||
group = parser.add_argument_group("Voice Settings")
|
||||
group.add_argument(
|
||||
"--voice-format",
|
||||
metavar="VOICE_FORMAT",
|
||||
default="wav",
|
||||
choices=["wav", "mp3", "webm"],
|
||||
help="Audio format for voice recording (default: wav). webm and mp3 require ffmpeg",
|
||||
)
|
||||
group.add_argument(
|
||||
"--voice-language",
|
||||
metavar="VOICE_LANGUAGE",
|
||||
default="en",
|
||||
help="Specify the language for voice using ISO 639-1 code (default: auto)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--voice-input-device",
|
||||
metavar="VOICE_INPUT_DEVICE",
|
||||
default=None,
|
||||
help="Specify the input device name for voice recording",
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue