mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
aider: Add --show-map option to print the repo map and then exit.
# Aider chat conversation: USER: add --show-map which will just print the repomap and then exit ASSISTANT: To add the `--show-map` option, we need to modify the `aider/main.py` file. We will add a new argument to the argument parser and then use this argument to conditionally print the repo map and exit. Here are the changes: ```python aider/main.py <<<<<<< ORIGINAL ########## other_group = parser.add_argument_group("Other Settings") other_group.add_argument( "--version", action="version", version=f"%(prog)s {__version__}", help="Show the version number and exit", ) ======= ########## other_group = parser.add_argument_group("Other Settings") other_group.add_argument( "--show-map", action="store_true", help="Print the repo map and exit", default=False, ) other_group.add_argument( "--version", action="version", version=f"%(prog)s {__version__}", help="Show the version number and exit", ) >>>>>>> UPDATED ``` ```python aider/main.py <<<<<<< ORIGINAL coder = Coder.create( main_model, args.edit_format, io, ## fnames=args.files, pretty=args.pretty, show_diffs=args.show_diffs, auto_commits=args.auto_commits, dirty_commits=args.dirty_commits, dry_run=args.dry_run, map_tokens=args.map_tokens, verbose=args.verbose, assistant_output_color=args.assistant_output_color, code_theme=args.code_theme, stream=args.stream, use_git=args.git, ) ======= if args.show_map: repo_map = RepoMap(map_tokens=args.map_tokens, root=git_root, main_model=main_model, io=io, verbose=args.verbose) print(repo_map) sys.exit(0) else: coder = Coder.create( main_model, args.edit_format, io, ## fnames=args.files, pretty=args.pretty, show_diffs=args.show_diffs, auto_commits=args.auto_commits, dirty_commits=args.dirty_commits, dry_run=args.dry_run, map_tokens=args.map_tokens, verbose=args.verbose, assistant_output_color=args.assistant_output_color, code_theme=args.code_theme, stream=args.stream, use_git=args.git, ) >>>>>>> UPDATED ``` Please note that the `RepoMap` class is used to create the repo map. If the `--show-map` option is used, the repo map is printed and the program exits. If not, the program continues as before.
This commit is contained in:
parent
e3aa9db5a2
commit
a10b08e8de
1 changed files with 29 additions and 18 deletions
|
@ -244,6 +244,12 @@ def main(args=None, input=None, output=None):
|
||||||
|
|
||||||
##########
|
##########
|
||||||
other_group = parser.add_argument_group("Other Settings")
|
other_group = parser.add_argument_group("Other Settings")
|
||||||
|
other_group.add_argument(
|
||||||
|
"--show-map",
|
||||||
|
action="store_true",
|
||||||
|
help="Print the repo map and exit",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
other_group.add_argument(
|
other_group.add_argument(
|
||||||
"--version",
|
"--version",
|
||||||
action="version",
|
action="version",
|
||||||
|
@ -363,24 +369,29 @@ def main(args=None, input=None, output=None):
|
||||||
setattr(openai, mod_key, val)
|
setattr(openai, mod_key, val)
|
||||||
io.tool_output(f"Setting openai.{mod_key}={val}")
|
io.tool_output(f"Setting openai.{mod_key}={val}")
|
||||||
|
|
||||||
coder = Coder.create(
|
if args.show_map:
|
||||||
main_model,
|
repo_map = RepoMap(map_tokens=args.map_tokens, root=git_root, main_model=main_model, io=io, verbose=args.verbose)
|
||||||
args.edit_format,
|
print(repo_map)
|
||||||
io,
|
sys.exit(0)
|
||||||
##
|
else:
|
||||||
fnames=args.files,
|
coder = Coder.create(
|
||||||
pretty=args.pretty,
|
main_model,
|
||||||
show_diffs=args.show_diffs,
|
args.edit_format,
|
||||||
auto_commits=args.auto_commits,
|
io,
|
||||||
dirty_commits=args.dirty_commits,
|
##
|
||||||
dry_run=args.dry_run,
|
fnames=args.files,
|
||||||
map_tokens=args.map_tokens,
|
pretty=args.pretty,
|
||||||
verbose=args.verbose,
|
show_diffs=args.show_diffs,
|
||||||
assistant_output_color=args.assistant_output_color,
|
auto_commits=args.auto_commits,
|
||||||
code_theme=args.code_theme,
|
dirty_commits=args.dirty_commits,
|
||||||
stream=args.stream,
|
dry_run=args.dry_run,
|
||||||
use_git=args.git,
|
map_tokens=args.map_tokens,
|
||||||
)
|
verbose=args.verbose,
|
||||||
|
assistant_output_color=args.assistant_output_color,
|
||||||
|
code_theme=args.code_theme,
|
||||||
|
stream=args.stream,
|
||||||
|
use_git=args.git,
|
||||||
|
)
|
||||||
|
|
||||||
if args.dirty_commits:
|
if args.dirty_commits:
|
||||||
coder.commit(ask=True, which="repo_files")
|
coder.commit(ask=True, which="repo_files")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue