From 3bb2958fb81a9cb6211e377b22041a70631529e5 Mon Sep 17 00:00:00 2001 From: Billy Date: Wed, 12 Jun 2024 16:51:49 +0900 Subject: [PATCH] feat: CLI - open directory/file command (smh) --- src/cli/editor.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/cli/editor.py b/src/cli/editor.py index 9ff29a3f..d6e893d1 100644 --- a/src/cli/editor.py +++ b/src/cli/editor.py @@ -10,6 +10,22 @@ from src import App +@click.command() +@click.argument( + "path", + type=click.Path( + exists=True, + dir_okay=True, + resolve_path=True, + ), + required=False, +) +def open(path=None) -> typing.Callable[[App, str], None]: + """Open a file or folder in the editor""" + + return lambda app, path=path: app.open(path) + + @click.command() @click.argument( "path", @@ -40,3 +56,4 @@ def goto(path=None, linecol=None) -> typing.Callable[[App, str], None]: def register(cli: click.Group): cli.add_command(goto) + cli.add_command(open)