refactor: improve GitHub issue reporting flow and user interaction

This commit is contained in:
Paul Gauthier 2024-08-29 07:39:48 -07:00 committed by Paul Gauthier (aider)
parent a227220efb
commit 9297e61c58

View file

@ -23,27 +23,29 @@ def report_github_issue(issue_text, title=None):
params["title"] = title params["title"] = title
issue_url = f"{base_url}?{urllib.parse.urlencode(params)}" issue_url = f"{base_url}?{urllib.parse.urlencode(params)}"
print("\nIssue Title:") print(f"\n# {title}\n")
print(title) print(issue_text.strip())
print("\nIssue Body:") print()
print(issue_text) prompt = "Report this as a GitHub Issue using your browser? (Y/n) "
print("\nDo you want to open this issue in your browser? (y/n)") confirmation = input(prompt).strip().lower()
confirmation = input().strip().lower()
if confirmation == "y": yes = not confirmation or confirmation.startswith("y")
try: if not yes:
print("Attempting to open the issue URL in your default web browser...") return
if webbrowser.open(issue_url):
print("Browser window should be opened.") print("Attempting to open the issue URL in your default web browser...")
else: try:
print("Unable to open browser window automatically.") if webbrowser.open(issue_url):
except Exception: print("Browser window should be opened.")
print() return
print("Please use this URL to file a GitHub issue:") except Exception:
print() pass
print(issue_url)
else: print()
print("Issue creation cancelled.") print("Unable to open browser window automatically.")
print("Please use this URL to file a GitHub issue:")
print()
print(issue_url)
if __name__ == "__main__": if __name__ == "__main__":