diff --git a/changelog.md b/changelog.md index de0ac40b..b01cd235 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,11 @@ +Upcoming (TBD) +============== + +Features +--------- +* Add `\bug` command. + + 1.57.0 (2026/02/25) ============== diff --git a/mycli/TIPS b/mycli/TIPS index fd004dad..82b16101 100644 --- a/mycli/TIPS +++ b/mycli/TIPS @@ -102,6 +102,8 @@ use "system " to execute a shell command! the "watch" command executes a query every N seconds! +use \bug to file a bug on GitHub! + ### ### general ### diff --git a/mycli/constants.py b/mycli/constants.py new file mode 100644 index 00000000..c461edf4 --- /dev/null +++ b/mycli/constants.py @@ -0,0 +1 @@ +ISSUES_URL = 'https://github.com/dbcli/mycli/issues' diff --git a/mycli/main.py b/mycli/main.py index e56df6ae..03a2418d 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -59,6 +59,7 @@ from mycli.compat import WIN from mycli.completion_refresher import CompletionRefresher from mycli.config import get_mylogin_cnf_path, open_mylogin_cnf, read_config_files, str_to_bool, strip_matching_quotes, write_default_config +from mycli.constants import ISSUES_URL from mycli.key_bindings import mycli_bindings from mycli.lexer import MyCliLexer from mycli.packages import special @@ -86,7 +87,7 @@ # Query tuples are used for maintaining history Query = namedtuple("Query", ["query", "successful", "mutating"]) -SUPPORT_INFO = "Home: https://mycli.net\nBug tracker: https://github.com/dbcli/mycli/issues" +SUPPORT_INFO = f"Home: https://mycli.net\nBug tracker: {ISSUES_URL}" DEFAULT_WIDTH = 80 DEFAULT_HEIGHT = 25 MIN_COMPLETION_TRIGGER = 1 diff --git a/mycli/packages/special/main.py b/mycli/packages/special/main.py index bcab3ed6..a6adb452 100644 --- a/mycli/packages/special/main.py +++ b/mycli/packages/special/main.py @@ -3,7 +3,9 @@ import logging import os from typing import Callable +import webbrowser +from mycli.constants import ISSUES_URL from mycli.packages.sqlresult import SQLResult try: @@ -186,6 +188,12 @@ def show_keyword_help(cur: Cursor, arg: str) -> list[SQLResult]: return [SQLResult(status=f'No help found for {keyword}.')] +@special_command('\\bug', '\\bug', 'File a bug on GitHub.', arg_type=ArgType.NO_QUERY) +def file_bug(*_args) -> list[SQLResult]: + webbrowser.open_new_tab(ISSUES_URL) + return [SQLResult(status=f'{ISSUES_URL} — press "New Issue"')] + + @special_command("exit", "exit", "Exit.", arg_type=ArgType.NO_QUERY, aliases=["\\q"]) @special_command("quit", "quit", "Quit.", arg_type=ArgType.NO_QUERY, aliases=["\\q"]) def quit_(*_args): diff --git a/test/features/fixture_data/help_commands.txt b/test/features/fixture_data/help_commands.txt index a12eb2c9..816053ad 100644 --- a/test/features/fixture_data/help_commands.txt +++ b/test/features/fixture_data/help_commands.txt @@ -2,6 +2,7 @@ | Command | Shortcut | Usage | Description | +----------------+----------+------------------------------+-------------------------------------------------------------+ | \G | | \G | Display query results vertically. | +| \bug | | \bug | File a bug on GitHub. | | \clip | | \clip | Copy query to the system clipboard. | | \dt | | \dt[+] [table] | List or describe tables. | | \e | | \e | \e | Edit query with editor (uses $EDITOR). |