mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00

# Context: USER: make -v short for --verbose ASSISTANT: To make `-v` a short option for `--verbose`, you can modify the `aider/main.py` file. Here's the change: ```python aider/main.py <<<<<<< ORIGINAL parser.add_argument( "--verbose", action="store_true", help="Enable verbose output", default=False, ) ======= parser.add_argument( "-v", "--verbose", action="store_true", help="Enable verbose output", default=False, ) >>>>>>> UPDATED ```
143 lines
4.1 KiB
Python
143 lines
4.1 KiB
Python
import os
|
|
import sys
|
|
import argparse
|
|
from dotenv import load_dotenv
|
|
from aider.coder import Coder
|
|
from aider.io import InputOutput
|
|
|
|
|
|
def main(args=None, input=None, output=None):
|
|
if args is None:
|
|
args = sys.argv[1:]
|
|
|
|
load_dotenv()
|
|
env_prefix = "AIDER_"
|
|
parser = argparse.ArgumentParser(description="aider - chat with GPT about your code")
|
|
parser.add_argument(
|
|
"files",
|
|
metavar="FILE",
|
|
nargs="*",
|
|
help="a list of source code files (optional)",
|
|
)
|
|
parser.add_argument(
|
|
"--input-history-file",
|
|
metavar="INPUT_HISTORY_FILE",
|
|
default=os.environ.get(f"{env_prefix}INPUT_HISTORY_FILE", ".aider.input.history"),
|
|
help=(
|
|
"Specify the chat input history file (default: .aider.input.history,"
|
|
f" ${env_prefix}INPUT_HISTORY_FILE)"
|
|
),
|
|
)
|
|
parser.add_argument(
|
|
"--chat-history-file",
|
|
metavar="CHAT_HISTORY_FILE",
|
|
default=os.environ.get(f"{env_prefix}CHAT_HISTORY_FILE", ".aider.chat.history.md"),
|
|
help=(
|
|
"Specify the chat history file (default: .aider.chat.history.md,"
|
|
f" ${env_prefix}CHAT_HISTORY_FILE)"
|
|
),
|
|
)
|
|
parser.add_argument(
|
|
"--model",
|
|
metavar="MODEL",
|
|
default=os.environ.get(f"{env_prefix}MODEL", "gpt-4"),
|
|
help=f"Specify the model to use for the main chat (default: gpt-4, ${env_prefix}MODEL)",
|
|
)
|
|
parser.add_argument(
|
|
"-3",
|
|
action="store_const",
|
|
dest="model",
|
|
const="gpt-3.5-turbo",
|
|
help="Use gpt-3.5-turbo model for the main chat (not advised)",
|
|
)
|
|
parser.add_argument(
|
|
"--no-pretty",
|
|
action="store_false",
|
|
dest="pretty",
|
|
help=f"Disable pretty, colorized output (${env_prefix}PRETTY)",
|
|
default=bool(int(os.environ.get(f"{env_prefix}PRETTY", 1))),
|
|
)
|
|
parser.add_argument(
|
|
"--apply",
|
|
metavar="FILE",
|
|
help="Apply the changes from the given file instead of running the chat (debug)",
|
|
)
|
|
parser.add_argument(
|
|
"--no-auto-commits",
|
|
action="store_false",
|
|
dest="auto_commits",
|
|
help=f"Disable auto commit of changes (${env_prefix}AUTO_COMMITS)",
|
|
default=bool(int(os.environ.get(f"{env_prefix}AUTO_COMMITS", 1))),
|
|
)
|
|
parser.add_argument(
|
|
"--dry-run",
|
|
action="store_true",
|
|
help="Perform a dry run without applying changes (default: False)",
|
|
default=False,
|
|
)
|
|
parser.add_argument(
|
|
"--show-diffs",
|
|
action="store_true",
|
|
help=f"Show diffs when committing changes (default: False, ${env_prefix}SHOW_DIFFS)",
|
|
default=bool(int(os.environ.get(f"{env_prefix}SHOW_DIFFS", 0))),
|
|
)
|
|
parser.add_argument(
|
|
"--ctags",
|
|
action="store_true",
|
|
help=(
|
|
"Add ctags to the chat to help GPT understand the codebase (default: False,"
|
|
f" ${env_prefix}CTAGS)"
|
|
),
|
|
default=bool(int(os.environ.get(f"{env_prefix}CTAGS", 0))),
|
|
)
|
|
parser.add_argument(
|
|
"--yes",
|
|
action="store_true",
|
|
help="Always say yes to every confirmation",
|
|
default=False,
|
|
)
|
|
parser.add_argument(
|
|
"-v", "--verbose",
|
|
action="store_true",
|
|
help="Enable verbose output",
|
|
default=False,
|
|
)
|
|
args = parser.parse_args(args)
|
|
|
|
io = InputOutput(
|
|
args.pretty,
|
|
args.yes,
|
|
args.input_history_file,
|
|
args.chat_history_file,
|
|
input=input,
|
|
output=output,
|
|
)
|
|
|
|
io.tool(*sys.argv, log_only=True)
|
|
|
|
coder = Coder(
|
|
io,
|
|
main_model=args.model,
|
|
fnames=args.files,
|
|
pretty=args.pretty,
|
|
show_diffs=args.show_diffs,
|
|
auto_commits=args.auto_commits,
|
|
dry_run=args.dry_run,
|
|
use_ctags=args.ctags,
|
|
verbose=args.verbose,
|
|
)
|
|
if args.auto_commits:
|
|
coder.commit(ask=True, prefix="wip: ", which="repo_files")
|
|
|
|
if args.apply:
|
|
with open(args.apply, "r") as f:
|
|
content = f.read()
|
|
coder.update_files(content, inp="")
|
|
return
|
|
|
|
coder.run()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
status = main()
|
|
sys.exit(status)
|