mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
main should use argv if args not provided
This commit is contained in:
parent
c368e87c9f
commit
d44f732d3b
2 changed files with 11 additions and 4 deletions
|
@ -5,7 +5,10 @@ from dotenv import load_dotenv
|
||||||
from aider.coder import Coder
|
from aider.coder import Coder
|
||||||
|
|
||||||
|
|
||||||
def main(argv=[]):
|
def main(args=None):
|
||||||
|
if not args:
|
||||||
|
args = sys.argv[1:]
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
env_prefix = "AIDER_"
|
env_prefix = "AIDER_"
|
||||||
parser = argparse.ArgumentParser(description="aider - chat with GPT about your code")
|
parser = argparse.ArgumentParser(description="aider - chat with GPT about your code")
|
||||||
|
@ -66,12 +69,15 @@ def main(argv=[]):
|
||||||
"--yes",
|
"--yes",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Always say yes to every confirmation",
|
help="Always say yes to every confirmation",
|
||||||
|
default=False,
|
||||||
)
|
)
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(args)
|
||||||
fnames = args.files
|
fnames = args.files
|
||||||
pretty = args.pretty
|
pretty = args.pretty
|
||||||
|
|
||||||
coder = Coder(args.model, fnames, pretty, args.history_file, args.show_diffs, args.auto_commits, args.yes)
|
coder = Coder(
|
||||||
|
args.model, fnames, pretty, args.history_file, args.show_diffs, args.auto_commits, args.yes
|
||||||
|
)
|
||||||
coder.commit(ask=True, prefix="wip: ", which="repo_files")
|
coder.commit(ask=True, prefix="wip: ", which="repo_files")
|
||||||
|
|
||||||
if args.apply:
|
if args.apply:
|
||||||
|
@ -84,5 +90,5 @@ def main(argv=[]):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
status = main(sys.argv[1:])
|
status = main()
|
||||||
sys.exit(status)
|
sys.exit(status)
|
||||||
|
|
|
@ -35,3 +35,4 @@ class TestMain(TestCase):
|
||||||
sys.stdin = dev_null
|
sys.stdin = dev_null
|
||||||
main(["--yes", "foo.txt"])
|
main(["--yes", "foo.txt"])
|
||||||
sys.stdin = save_stdin
|
sys.stdin = save_stdin
|
||||||
|
self.assertTrue(os.path.exists("foo.txt"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue