mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 03:27:34 +00:00
Add rename service and utility modules for file renaming operations
- Implemented RenameService for handling file renaming with features like name validation, proposed name generation, conflict detection, and atomic rename operations. - Created utility modules for language code extraction, regex pattern matching, and frame class matching to centralize common functionalities. - Added comprehensive logging for error handling and debugging across all new modules.
This commit is contained in:
+30
-2
@@ -57,6 +57,34 @@ class CacheCommandProvider(Provider):
|
||||
)
|
||||
|
||||
|
||||
class AppCommandProvider(Provider):
|
||||
"""Command provider for main application operations."""
|
||||
|
||||
async def search(self, query: str):
|
||||
"""Search for app commands matching the query."""
|
||||
matcher = self.matcher(query)
|
||||
|
||||
commands = [
|
||||
("open", "Open Directory", "Open a directory to browse media files (o)"),
|
||||
("scan", "Scan Directory", "Scan current directory for media files (s)"),
|
||||
("refresh", "Refresh File", "Refresh metadata for selected file (f)"),
|
||||
("rename", "Rename File", "Rename the selected file (r)"),
|
||||
("toggle_mode", "Toggle Display Mode", "Switch between technical and catalog view (m)"),
|
||||
("expand", "Toggle Tree Expansion", "Expand or collapse all tree nodes (p)"),
|
||||
("settings", "Settings", "Open settings screen (Ctrl+S)"),
|
||||
("help", "Help", "Show keyboard shortcuts and help (h)"),
|
||||
]
|
||||
|
||||
for command_name, display_name, help_text in commands:
|
||||
if (score := matcher.match(display_name)) > 0:
|
||||
yield Hit(
|
||||
score,
|
||||
matcher.highlight(display_name),
|
||||
partial(self.app.run_action, command_name),
|
||||
help=help_text
|
||||
)
|
||||
|
||||
|
||||
class RenamerApp(App):
|
||||
CSS = """
|
||||
#left {
|
||||
@@ -81,8 +109,8 @@ class RenamerApp(App):
|
||||
("ctrl+s", "settings", "Settings"),
|
||||
]
|
||||
|
||||
# Command palette - extend built-in commands with cache commands
|
||||
COMMANDS = App.COMMANDS | {CacheCommandProvider}
|
||||
# Command palette - extend built-in commands with cache and app commands
|
||||
COMMANDS = App.COMMANDS | {CacheCommandProvider, AppCommandProvider}
|
||||
|
||||
def __init__(self, scan_dir):
|
||||
super().__init__()
|
||||
|
||||
Reference in New Issue
Block a user