Skip to content

Commit

Permalink
Update version and prepare new release
Browse files Browse the repository at this point in the history
  • Loading branch information
anze3db committed Jul 5, 2024
1 parent 759538c commit ed1bd91
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 46 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Calendar Versioning](https://calver.org).

## [24.3] - 2024-07-05

### Added

Command highlighting on Python 3.12
Django 5.1 support

### Fixed

Crash on startup when used with older Textual versions
Bug that prevented commands from working


## [24.2] - 2024-03-29

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ classifiers = [
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -36,8 +37,7 @@ classifiers = [
]
dependencies = [
"django>=3.2",
"textual[syntax]>=0.54.0 ; python_version < '3.12'",
"textual>=0.54.0 ; python_version >= '3.12'", # tree-sitter-languages doesn't support 3.12 yet (https://github.com/grantjenks/py-tree-sitter-languages/issues/30)
"textual[syntax]>=0.64.0",
"trogon",
]

Expand Down
2 changes: 1 addition & 1 deletion src/django_tui/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023-present Anže Pečar <[email protected]>
#
# SPDX-License-Identifier: MIT
__version__ = "24.2"
__version__ = "24.3"
15 changes: 10 additions & 5 deletions src/django_tui/management/commands/ish.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,7 @@ def compose(self) -> ComposeResult:

class DefaultImportsInfo(ModalScreen[None]):
BINDINGS = [
Binding(
"escape",
"dismiss(None)",
"Close",
),
Binding("escape", "dismiss(None)", "Close"),
]

DEFAULT_CSS = """
Expand Down Expand Up @@ -394,3 +390,12 @@ def action_toggle_comment(self) -> None:

def action_editor_keys(self) -> None:
self.app.push_screen(TextEditorBindingsInfo())

def action_select_mode(self, mode_id: Literal["commands", "shell"]) -> None:
if mode_id == "commands":
from django_tui.management.commands.tui import DjangoCommandBuilder

self.app.push_screen(DjangoCommandBuilder("pyhton manage.py", "Test command name"))

elif mode_id == "shell":
self.app.push_screen(InteractiveShellScreen("Interactive Shell"))
57 changes: 19 additions & 38 deletions src/django_tui/management/commands/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class AboutDialog(TextDialog):
"""

def __init__(self) -> None:
title = f"About django-tui"
title = "About django-tui"
message = Text.from_markup(
"Built with [@click=app.visit('https://github.com/textualize/textual')]Textual[/] & [@click=app.visit('https://github.com/textualize/trogon')]Trogon[/] "
"by [@click=app.visit('https://pecar.me')]Anže Pečar[/].\n\n"
Expand All @@ -168,17 +168,6 @@ def __init__(self) -> None:
class DjangoCommandBuilder(Screen):
COMPONENT_CLASSES = {"version-string", "prompt", "command-name-syntax"}

BINDINGS = [
Binding(key="ctrl+r", action="close_and_run", description="Close & Run"),
Binding(key="ctrl+z", action="copy_command", description="Copy Command to Clipboard"),
Binding(key="ctrl+t", action="focus_command_tree", description="Focus Command Tree"),
# Binding(key="ctrl+o", action="show_command_info", description="Command Info"),
Binding(key="ctrl+s", action="focus('search')", description="Search"),
Binding(key="ctrl+j", action="select_mode('shell')", description="Shell"),
("escape", "app.back", "Back"),
Binding(key="f1", action="about", description="About"),
]

def __init__(
self,
click_app_name: str,
Expand Down Expand Up @@ -257,32 +246,6 @@ def action_close_and_run(self) -> None:
self.app.execute_on_exit = True
self.app.exit()

def action_copy_command(self) -> None:
if self.command_data is None:
return

if sys.platform == "win32":
copy_command = ["clip"]
elif sys.platform == "darwin":
copy_command = ["pbcopy"]
else:
copy_command = ["xclip", "-selection", "clipboard"]

try:
command = self.click_app_name + " " + " ".join(shlex.quote(str(x)) for x in self.command_data.to_cli_args())
run(
copy_command,
input=command,
text=True,
check=False,
)
self.notify(f"`{command}` copied to clipboard.")
except FileNotFoundError:
self.notify(f"Could not copy to clipboard. `{copy_command[0]}` not found.", severity="error")

def action_about(self) -> None:
self.app.push_screen(AboutDialog())

async def on_mount(self, event: events.Mount) -> None:
await self._refresh_command_form()

Expand Down Expand Up @@ -347,6 +310,16 @@ async def _update_form_body(self, node: TreeNode[CommandSchema]) -> None:
class DjangoTui(App):
CSS_PATH = Path(__file__).parent / "trogon.scss"

BINDINGS = [
Binding(key="ctrl+r", action="close_and_run", description="Close & Run"),
Binding(key="ctrl+z", action="copy_command", description="Copy Command to Clipboard"),
Binding(key="ctrl+t", action="focus_command_tree", description="Focus Command Tree"),
# Binding(key="ctrl+o", action="show_command_info", description="Command Info"),
Binding(key="ctrl+s", action="focus('search')", description="Search"),
Binding(key="ctrl+j", action="select_mode('shell')", description="Shell"),
Binding(key="f1", action="about", description="About"),
]

def __init__(
self,
*,
Expand Down Expand Up @@ -426,6 +399,14 @@ def action_select_mode(self, mode_id: Literal["commands", "shell"]) -> None:
elif mode_id == "shell":
self.app.push_screen(InteractiveShellScreen("Interactive Shell"))

def action_copy_command(self) -> None:
command = self.app_name + " " + " ".join(shlex.quote(str(x)) for x in self.post_run_command)
self.copy_to_clipboard(command)
self.notify(f"`{command}` copied to clipboard.")

def action_about(self) -> None:
self.app.push_screen(AboutDialog())


class Command(BaseCommand):
help = """Run and inspect Django commands in a text-based user interface (TUI)."""
Expand Down

0 comments on commit ed1bd91

Please sign in to comment.