Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions concore_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,17 @@ def setup(dry_run, force):
sys.exit(1)


@cli.command()
def editor():
"""Launch concore-editor"""
try:
from .commands.editor import launch_editor

launch_editor()
except Exception as e:
console.print(f"[red]Error:[/red] {str(e)}")
sys.exit(1)


if __name__ == "__main__":
cli()
32 changes: 32 additions & 0 deletions concore_cli/commands/editor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
import sys
import shutil
import subprocess
from rich.console import Console

console = Console()
EDITOR_URL = "https://controlcore-project.github.io/concore-editor/"


def open_editor_url(url):
try:
if sys.platform == "win32":
os.system(f'start "" chrome "{url}"')
else:
if shutil.which("open"):
if sys.platform == "darwin":
subprocess.run(["open", "-a", "Google Chrome", url])
elif sys.platform.startswith("linux"):
subprocess.run(["xdg-open", url])
else:
if shutil.which("xdg-open"):
subprocess.run(["xdg-open", url])
else:
console.print("unable to open browser for the concore editor.")
except Exception as e:
console.print(f"unable to open browser for the concore editor. ({e})")


def launch_editor():
console.print("[cyan]Opening concore-editor...[/cyan]")
open_editor_url(EDITOR_URL)
Loading