output nice md usage

This commit is contained in:
Paul Gauthier 2024-06-06 12:26:06 -07:00
parent 8e9cbcc014
commit caca261587
3 changed files with 411 additions and 174 deletions

View file

@ -7,13 +7,14 @@ import sys
import configargparse
from aider import __version__, models
from aider.args_formatter import CustomHelpFormatter
from aider.args_formatter import MarkdownHelpFormatter
from .dump import dump # noqa: F401
def get_parser(default_config_files, git_root):
parser = configargparse.ArgumentParser(
description="aider is GPT powered coding in your terminal",
formatter_class=CustomHelpFormatter,
add_config_file_help=True,
default_config_files=default_config_files,
auto_env_var_prefix="AIDER_",
@ -455,9 +456,15 @@ def get_parser(default_config_files, git_root):
def get_help():
os.environ["COLUMNS"] = "100"
sys.argv[0] = "aider"
sys.argv = ["aider"]
parser = get_parser([], None)
parser.formatter_class = CustomHelpFormatter
# This instantiates all the action.env_var values
parser.parse_known_args()
parser.formatter_class = MarkdownHelpFormatter
return argparse.ArgumentParser.format_help(parser)
return parser.format_help()

View file

@ -2,42 +2,48 @@ import argparse
from .dump import dump # noqa: F401
class MarkdownHelpFormatter(argparse.HelpFormatter):
def start_section(self, heading):
super().start_section(f"## {heading}")
def _format_usage(self, usage, actions, groups, prefix):
res = super()._format_usage(usage, actions, groups, prefix)
quote = "```\n"
return quote + res + quote
def _format_text(self, text):
return ""
def _format_action(self, action):
parts = [""]
#action: _StoreAction(option_strings=['--message', '--msg', '-m'], dest='message', nargs=None, const=None, default=None, type=None, choices=None, required=False, help='Specify a single message to send the LLM, process reply then exit (disables chat mode)', metavar='COMMAND')
dump(action)
metavar = action.metavar
if not metavar and isinstance(action, argparse._StoreAction):
metavar = 'VALUE'
metavar = "VALUE"
if metavar:
parts.append(f"### --{action.dest} {metavar}")
parts.append(f"### `--{action.dest} {metavar}`")
else:
parts.append(f"### --{action.dest}")
parts.append(f"### `--{action.dest}`")
if action.help:
parts.append(action.help)
parts.append(action.help + " ")
if action.default is not argparse.SUPPRESS:
parts.append(f"- Default: {action.default}")
if len(action.option_strings) > 1:
parts.append("- Aliases:")
for switch in action.option_strings:
if metavar:
parts.append(f" - {switch} {metavar}")
else:
parts.append(f" - {switch}")
if action.default not in (argparse.SUPPRESS, None):
parts.append(f"Default: {action.default} ")
if action.env_var:
parts.append(f"- Env: {action.env_var}")
parts.append(f"Environment variable: `{action.env_var}` ")
return "\n".join(parts) + '\n'
if len(action.option_strings) > 1:
parts.append("Aliases:")
for switch in action.option_strings:
if metavar:
parts.append(f" - `{switch} {metavar}`")
else:
parts.append(f" - `{switch}`")
return "\n".join(parts) + "\n"
def _format_action_invocation(self, action):
return ""

View file

@ -10,161 +10,385 @@ or review them below.
<!--[[[cog
from aider.args import get_help
cog.outl("```")
cog.out(get_help())
cog.outl("```")
]]]-->
```
usage: aider [-h] [--openai-api-key OPENAI_API_KEY] [--anthropic-api-key ANTHROPIC_API_KEY]
[--model MODEL] [--opus] [--sonnet] [--4] [--4o] [--4-turbo] [--35turbo]
[--models MODEL] [--openai-api-base OPENAI_API_BASE]
[--openai-api-type OPENAI_API_TYPE] [--openai-api-version OPENAI_API_VERSION]
[--openai-api-deployment-id OPENAI_API_DEPLOYMENT_ID]
[--openai-organization-id OPENAI_ORGANIZATION_ID] [--edit-format EDIT_FORMAT]
[--weak-model WEAK_MODEL] [--show-model-warnings | --no-show-model-warnings]
[--map-tokens MAP_TOKENS] [--max-chat-history-tokens MAX_CHAT_HISTORY_TOKENS]
[--env-file ENV_FILE] [--input-history-file INPUT_HISTORY_FILE]
[--chat-history-file CHAT_HISTORY_FILE]
[--restore-chat-history | --no-restore-chat-history] [--dark-mode] [--light-mode]
[--pretty | --no-pretty] [--stream | --no-stream]
[--user-input-color USER_INPUT_COLOR] [--tool-output-color TOOL_OUTPUT_COLOR]
[--tool-error-color TOOL_ERROR_COLOR]
[--assistant-output-color ASSISTANT_OUTPUT_COLOR] [--code-theme CODE_THEME]
[--show-diffs] [--git | --no-git] [--gitignore | --no-gitignore]
[--aiderignore AIDERIGNORE] [--auto-commits | --no-auto-commits]
usage: aider [-h] [--openai-api-key] [--anthropic-api-key] [--model] [--opus] [--sonnet] [--4]
[--4o] [--4-turbo] [--35turbo] [--models] [--openai-api-base] [--openai-api-type]
[--openai-api-version] [--openai-api-deployment-id] [--openai-organization-id]
[--edit-format] [--weak-model] [--show-model-warnings | --no-show-model-warnings]
[--map-tokens] [--max-chat-history-tokens] [--env-file] [--input-history-file]
[--chat-history-file] [--restore-chat-history | --no-restore-chat-history]
[--dark-mode] [--light-mode] [--pretty | --no-pretty] [--stream | --no-stream]
[--user-input-color] [--tool-output-color] [--tool-error-color]
[--assistant-output-color] [--code-theme] [--show-diffs] [--git | --no-git]
[--gitignore | --no-gitignore] [--aiderignore] [--auto-commits | --no-auto-commits]
[--dirty-commits | --no-dirty-commits] [--dry-run | --no-dry-run] [--commit] [--lint]
[--lint-cmd LINT_CMD] [--auto-lint | --no-auto-lint] [--test-cmd TEST_CMD]
[--auto-test | --no-auto-test] [--test] [--voice-language VOICE_LANGUAGE] [--version]
[--check-update] [--skip-check-update] [--apply FILE] [--yes] [-v] [--show-repo-map]
[--show-prompts] [--message COMMAND] [--message-file MESSAGE_FILE]
[--encoding ENCODING] [-c CONFIG_FILE] [--gui]
[FILE ...]
[--lint-cmd] [--auto-lint | --no-auto-lint] [--test-cmd]
[--auto-test | --no-auto-test] [--test] [--voice-language] [--version]
[--check-update] [--skip-check-update] [--apply] [--yes] [-v] [--show-repo-map]
[--show-prompts] [--message] [--message-file] [--encoding] [-c] [--gui]
aider is GPT powered coding in your terminal
options:
-h, --help show this help message and exit
Main:
FILE files to edit with an LLM (optional)
--openai-api-key OPENAI_API_KEY
Specify the OpenAI API key [env var: OPENAI_API_KEY]
--anthropic-api-key ANTHROPIC_API_KEY
Specify the OpenAI API key [env var: ANTHROPIC_API_KEY]
--model MODEL Specify the model to use for the main chat (default: gpt-4o)
--opus Use claude-3-opus-20240229 model for the main chat
--sonnet Use claude-3-sonnet-20240229 model for the main chat
--4, -4 Use gpt-4-0613 model for the main chat
--4o Use gpt-4o model for the main chat
--4-turbo Use gpt-4-1106-preview model for the main chat
--35turbo, --35-turbo, --3, -3
Use gpt-3.5-turbo model for the main chat
Model Settings:
--models MODEL List known models which match the (partial) MODEL name
--openai-api-base OPENAI_API_BASE
Specify the api base url [env var: OPENAI_API_BASE]
--openai-api-type OPENAI_API_TYPE
Specify the api_type [env var: OPENAI_API_TYPE]
--openai-api-version OPENAI_API_VERSION
Specify the api_version [env var: OPENAI_API_VERSION]
--openai-api-deployment-id OPENAI_API_DEPLOYMENT_ID
Specify the deployment_id [env var: OPENAI_API_DEPLOYMENT_ID]
--openai-organization-id OPENAI_ORGANIZATION_ID
Specify the OpenAI organization ID [env var: OPENAI_ORGANIZATION_ID]
--edit-format EDIT_FORMAT
Specify what edit format the LLM should use (default depends on model)
--weak-model WEAK_MODEL
Specify the model to use for commit messages and chat history
summarization (default depends on --model)
--show-model-warnings, --no-show-model-warnings
Only work with models that have meta-data available (default: True)
--map-tokens MAP_TOKENS
Max number of tokens to use for repo map, use 0 to disable (default: 1024)
--max-chat-history-tokens MAX_CHAT_HISTORY_TOKENS
Maximum number of tokens to use for chat history. If not specified, uses
the model's max_chat_history_tokens.
--env-file ENV_FILE Specify the .env file to load (default: .env in git root)
History Files:
--input-history-file INPUT_HISTORY_FILE
Specify the chat input history file (default: .aider.input.history)
--chat-history-file CHAT_HISTORY_FILE
Specify the chat history file (default: .aider.chat.history.md)
--restore-chat-history, --no-restore-chat-history
Restore the previous chat history messages (default: False)
Output Settings:
--dark-mode Use colors suitable for a dark terminal background (default: False)
--light-mode Use colors suitable for a light terminal background (default: False)
--pretty, --no-pretty
Enable/disable pretty, colorized output (default: True)
--stream, --no-stream
Enable/disable streaming responses (default: True)
--user-input-color USER_INPUT_COLOR
Set the color for user input (default: #00cc00)
--tool-output-color TOOL_OUTPUT_COLOR
Set the color for tool output (default: None)
--tool-error-color TOOL_ERROR_COLOR
Set the color for tool error messages (default: red)
--assistant-output-color ASSISTANT_OUTPUT_COLOR
Set the color for assistant output (default: #0088ff)
--code-theme CODE_THEME
Set the markdown code theme (default: default, other options include
monokai, solarized-dark, solarized-light)
--show-diffs Show diffs when committing changes (default: False)
Git Settings:
--git, --no-git Enable/disable looking for a git repo (default: True)
--gitignore, --no-gitignore
Enable/disable adding .aider* to .gitignore (default: True)
--aiderignore AIDERIGNORE
Specify the aider ignore file (default: .aiderignore in git root)
--auto-commits, --no-auto-commits
Enable/disable auto commit of LLM changes (default: True)
--dirty-commits, --no-dirty-commits
Enable/disable commits when repo is found dirty (default: True)
--dry-run, --no-dry-run
Perform a dry run without modifying files (default: False)
Fixing and committing:
--commit Commit all pending changes with a suitable commit message, then exit
--lint Lint and fix provided files, or dirty files if none provided
--lint-cmd LINT_CMD Specify lint commands to run for different languages, eg: "python: flake8
--select=..." (can be used multiple times)
--auto-lint, --no-auto-lint
Enable/disable automatic linting after changes (default: True)
--test-cmd TEST_CMD Specify command to run tests
--auto-test, --no-auto-test
Enable/disable automatic testing after changes (default: False)
--test Run tests and fix problems found
Other Settings:
--voice-language VOICE_LANGUAGE
Specify the language for voice using ISO 639-1 code (default: auto)
--version Show the version number and exit
--check-update Check for updates and return status in the exit code
--skip-check-update Skips checking for the update when the program runs
--apply FILE Apply the changes from the given file instead of running the chat (debug)
--yes Always say yes to every confirmation
-v, --verbose Enable verbose output
--show-repo-map Print the repo map and exit (debug)
--show-prompts Print the system prompts and exit (debug)
--message COMMAND, --msg COMMAND, -m COMMAND
Specify a single message to send the LLM, process reply then exit
(disables chat mode)
--message-file MESSAGE_FILE, -f MESSAGE_FILE
Specify a file containing the message to send the LLM, process reply, then
exit (disables chat mode)
--encoding ENCODING Specify the encoding for input and output (default: utf-8)
-c CONFIG_FILE, --config CONFIG_FILE
Specify the config file (default: search for .aider.conf.yml in git root,
cwd or home directory)
--gui, --browser Run aider in your browser
Args that start with '--' can also be set in a config file (specified via -c). Config file syntax
allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at https://goo.gl/R74nmi). In
general, command-line values override environment variables which override config file values
which override defaults.
```
## options:
### `--help`
show this help message and exit
Aliases:
- `-h`
- `--help`
## Main:
### `--files FILE`
files to edit with an LLM (optional)
### `--openai_api_key OPENAI_API_KEY`
Specify the OpenAI API key
Environment variable: `OPENAI_API_KEY`
### `--anthropic_api_key ANTHROPIC_API_KEY`
Specify the OpenAI API key
Environment variable: `ANTHROPIC_API_KEY`
### `--model MODEL`
Specify the model to use for the main chat (default: gpt-4o)
Default: gpt-4o
Environment variable: `AIDER_MODEL`
### `--model`
Use claude-3-opus-20240229 model for the main chat
Environment variable: `AIDER_OPUS`
### `--model`
Use claude-3-sonnet-20240229 model for the main chat
Environment variable: `AIDER_SONNET`
### `--model`
Use gpt-4-0613 model for the main chat
Environment variable: `AIDER_4`
Aliases:
- `--4`
- `-4`
### `--model`
Use gpt-4o model for the main chat
Environment variable: `AIDER_4O`
### `--model`
Use gpt-4-1106-preview model for the main chat
Environment variable: `AIDER_4_TURBO`
### `--model`
Use gpt-3.5-turbo model for the main chat
Environment variable: `AIDER_35TURBO`
Aliases:
- `--35turbo`
- `--35-turbo`
- `--3`
- `-3`
## Model Settings:
### `--models MODEL`
List known models which match the (partial) MODEL name
Environment variable: `AIDER_MODELS`
### `--openai_api_base OPENAI_API_BASE`
Specify the api base url
Environment variable: `OPENAI_API_BASE`
### `--openai_api_type OPENAI_API_TYPE`
Specify the api_type
Environment variable: `OPENAI_API_TYPE`
### `--openai_api_version OPENAI_API_VERSION`
Specify the api_version
Environment variable: `OPENAI_API_VERSION`
### `--openai_api_deployment_id OPENAI_API_DEPLOYMENT_ID`
Specify the deployment_id
Environment variable: `OPENAI_API_DEPLOYMENT_ID`
### `--openai_organization_id OPENAI_ORGANIZATION_ID`
Specify the OpenAI organization ID
Environment variable: `OPENAI_ORGANIZATION_ID`
### `--edit_format EDIT_FORMAT`
Specify what edit format the LLM should use (default depends on model)
Environment variable: `AIDER_EDIT_FORMAT`
### `--weak_model WEAK_MODEL`
Specify the model to use for commit messages and chat history summarization (default depends on --model)
Environment variable: `AIDER_WEAK_MODEL`
### `--show_model_warnings`
Only work with models that have meta-data available (default: True)
Default: True
Environment variable: `AIDER_SHOW_MODEL_WARNINGS`
Aliases:
- `--show-model-warnings`
- `--no-show-model-warnings`
### `--map_tokens VALUE`
Max number of tokens to use for repo map, use 0 to disable (default: 1024)
Default: 1024
Environment variable: `AIDER_MAP_TOKENS`
### `--max_chat_history_tokens VALUE`
Maximum number of tokens to use for chat history. If not specified, uses the model's max_chat_history_tokens.
Environment variable: `AIDER_MAX_CHAT_HISTORY_TOKENS`
### `--env_file ENV_FILE`
Specify the .env file to load (default: .env in git root)
Default: .env
Environment variable: `AIDER_ENV_FILE`
## History Files:
### `--input_history_file INPUT_HISTORY_FILE`
Specify the chat input history file (default: .aider.input.history)
Default: .aider.input.history
Environment variable: `AIDER_INPUT_HISTORY_FILE`
### `--chat_history_file CHAT_HISTORY_FILE`
Specify the chat history file (default: .aider.chat.history.md)
Default: .aider.chat.history.md
Environment variable: `AIDER_CHAT_HISTORY_FILE`
### `--restore_chat_history`
Restore the previous chat history messages (default: False)
Default: False
Environment variable: `AIDER_RESTORE_CHAT_HISTORY`
Aliases:
- `--restore-chat-history`
- `--no-restore-chat-history`
## Output Settings:
### `--dark_mode`
Use colors suitable for a dark terminal background (default: False)
Default: False
Environment variable: `AIDER_DARK_MODE`
### `--light_mode`
Use colors suitable for a light terminal background (default: False)
Default: False
Environment variable: `AIDER_LIGHT_MODE`
### `--pretty`
Enable/disable pretty, colorized output (default: True)
Default: True
Environment variable: `AIDER_PRETTY`
Aliases:
- `--pretty`
- `--no-pretty`
### `--stream`
Enable/disable streaming responses (default: True)
Default: True
Environment variable: `AIDER_STREAM`
Aliases:
- `--stream`
- `--no-stream`
### `--user_input_color VALUE`
Set the color for user input (default: #00cc00)
Default: #00cc00
Environment variable: `AIDER_USER_INPUT_COLOR`
### `--tool_output_color VALUE`
Set the color for tool output (default: None)
Environment variable: `AIDER_TOOL_OUTPUT_COLOR`
### `--tool_error_color VALUE`
Set the color for tool error messages (default: red)
Default: #FF2222
Environment variable: `AIDER_TOOL_ERROR_COLOR`
### `--assistant_output_color VALUE`
Set the color for assistant output (default: #0088ff)
Default: #0088ff
Environment variable: `AIDER_ASSISTANT_OUTPUT_COLOR`
### `--code_theme VALUE`
Set the markdown code theme (default: default, other options include monokai, solarized-dark, solarized-light)
Default: default
Environment variable: `AIDER_CODE_THEME`
### `--show_diffs`
Show diffs when committing changes (default: False)
Default: False
Environment variable: `AIDER_SHOW_DIFFS`
## Git Settings:
### `--git`
Enable/disable looking for a git repo (default: True)
Default: True
Environment variable: `AIDER_GIT`
Aliases:
- `--git`
- `--no-git`
### `--gitignore`
Enable/disable adding .aider* to .gitignore (default: True)
Default: True
Environment variable: `AIDER_GITIGNORE`
Aliases:
- `--gitignore`
- `--no-gitignore`
### `--aiderignore AIDERIGNORE`
Specify the aider ignore file (default: .aiderignore in git root)
Default: .aiderignore
Environment variable: `AIDER_AIDERIGNORE`
### `--auto_commits`
Enable/disable auto commit of LLM changes (default: True)
Default: True
Environment variable: `AIDER_AUTO_COMMITS`
Aliases:
- `--auto-commits`
- `--no-auto-commits`
### `--dirty_commits`
Enable/disable commits when repo is found dirty (default: True)
Default: True
Environment variable: `AIDER_DIRTY_COMMITS`
Aliases:
- `--dirty-commits`
- `--no-dirty-commits`
### `--dry_run`
Perform a dry run without modifying files (default: False)
Default: False
Environment variable: `AIDER_DRY_RUN`
Aliases:
- `--dry-run`
- `--no-dry-run`
## Fixing and committing:
### `--commit`
Commit all pending changes with a suitable commit message, then exit
Default: False
Environment variable: `AIDER_COMMIT`
### `--lint`
Lint and fix provided files, or dirty files if none provided
Default: False
Environment variable: `AIDER_LINT`
### `--lint_cmd`
Specify lint commands to run for different languages, eg: "python: flake8 --select=..." (can be used multiple times)
Default: []
Environment variable: `AIDER_LINT_CMD`
### `--auto_lint`
Enable/disable automatic linting after changes (default: True)
Default: True
Environment variable: `AIDER_AUTO_LINT`
Aliases:
- `--auto-lint`
- `--no-auto-lint`
### `--test_cmd`
Specify command to run tests
Default: []
Environment variable: `AIDER_TEST_CMD`
### `--auto_test`
Enable/disable automatic testing after changes (default: False)
Default: False
Environment variable: `AIDER_AUTO_TEST`
Aliases:
- `--auto-test`
- `--no-auto-test`
### `--test`
Run tests and fix problems found
Default: False
Environment variable: `AIDER_TEST`
## Other Settings:
### `--voice_language VOICE_LANGUAGE`
Specify the language for voice using ISO 639-1 code (default: auto)
Default: en
Environment variable: `AIDER_VOICE_LANGUAGE`
### `--version`
Show the version number and exit
### `--check_update`
Check for updates and return status in the exit code
Default: False
Environment variable: `AIDER_CHECK_UPDATE`
### `--skip_check_update`
Skips checking for the update when the program runs
Default: False
Environment variable: `AIDER_SKIP_CHECK_UPDATE`
### `--apply FILE`
Apply the changes from the given file instead of running the chat (debug)
Environment variable: `AIDER_APPLY`
### `--yes`
Always say yes to every confirmation
Environment variable: `AIDER_YES`
### `--verbose`
Enable verbose output
Default: False
Environment variable: `AIDER_VERBOSE`
Aliases:
- `-v`
- `--verbose`
### `--show_repo_map`
Print the repo map and exit (debug)
Default: False
Environment variable: `AIDER_SHOW_REPO_MAP`
### `--show_prompts`
Print the system prompts and exit (debug)
Default: False
Environment variable: `AIDER_SHOW_PROMPTS`
### `--message COMMAND`
Specify a single message to send the LLM, process reply then exit (disables chat mode)
Environment variable: `AIDER_MESSAGE`
Aliases:
- `--message COMMAND`
- `--msg COMMAND`
- `-m COMMAND`
### `--message_file MESSAGE_FILE`
Specify a file containing the message to send the LLM, process reply, then exit (disables chat mode)
Environment variable: `AIDER_MESSAGE_FILE`
Aliases:
- `--message-file MESSAGE_FILE`
- `-f MESSAGE_FILE`
### `--encoding VALUE`
Specify the encoding for input and output (default: utf-8)
Default: utf-8
Environment variable: `AIDER_ENCODING`
### `--config CONFIG_FILE`
Specify the config file (default: search for .aider.conf.yml in git root, cwd or home directory)
Aliases:
- `-c CONFIG_FILE`
- `--config CONFIG_FILE`
### `--gui`
Run aider in your browser
Default: False
Environment variable: `AIDER_GUI`
Aliases:
- `--gui`
- `--browser`
<!--[[[end]]]-->