Skip to content

Commit

Permalink
Merge pull request #36 from Wytamma/share
Browse files Browse the repository at this point in the history
Add --share to cli
  • Loading branch information
Wytamma authored Mar 1, 2024
2 parents c34d492 + 348c1e3 commit 413da74
Show file tree
Hide file tree
Showing 53 changed files with 175 additions and 278 deletions.
26 changes: 18 additions & 8 deletions backend/beastiary/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid
import typer
import uvicorn
from with_cloudflared import cloudflared

from pathlib import Path
from typing import List, Optional
Expand All @@ -14,7 +15,7 @@
app = typer.Typer()


@app.command()
@app.command(context_settings={"help_option_names": ["-h", "--help"]})
def main(
log_files: Optional[List[Path]] = typer.Argument(
None,
Expand All @@ -27,10 +28,11 @@ def main(
token: str = typer.Option(str(uuid.uuid4()), "--token", "-t"),
host: str = typer.Option("127.0.0.1", "--host"),
port: str = typer.Option(5000, "--port"),
security: bool = typer.Option(True, help="Turn off token requirement."),
debug: bool = typer.Option(False, help="Set debug mode."),
share: bool = typer.Option(False, "--share", help="Create a publicly shareable link."),
no_security: bool = typer.Option(False, "--no-security", help="Turn off token requirement."),
delimiter: str = typer.Option("\t", "--delimiter", help="Delimiter to split file columns on. Default is tab."),
debug: bool = typer.Option(False, "--debug", help="Set debug mode."),
testing: bool = typer.Option(False, help="Only for testing.", hidden=True),
delimiter: str = typer.Option("\t", "--delimiter"),
) -> None:
"""
Realtime and remote trace inspection with BEASTIARY.
Expand Down Expand Up @@ -62,14 +64,22 @@ def main(
f"http://{host}:{port}/login?token={token}", fg=typer.colors.GREEN, bold=False
)
typer.echo(f"Go to: {url}\n")
if security:
typer.echo(f"If prompted enter token: {token}")
else:
if no_security:
warning = typer.style("WARNING", fg=typer.colors.YELLOW, bold=True)
typer.echo(f"{warning}: Security disabled!")
setattr(api, "security", False)
else:
typer.echo(f"If prompted enter token: {token}\n")
log_level = "warning"
if debug:
log_level = "debug"
if not testing:
if testing:
typer.Exit()
if share:
typer.echo("Creating public shareable link...")
with cloudflared(port=port) as cloudflared_url:
url_with_token = typer.style(f"{cloudflared_url}", fg=typer.colors.GREEN, bold=False)
typer.echo(f"\nBeastiary is now publicly accessible at: {url_with_token}")
uvicorn.run(api, host=host, port=port, log_level=log_level)
else:
uvicorn.run(api, host=host, port=port, log_level=log_level)
5 changes: 0 additions & 5 deletions backend/beastiary/webapp-dist/css/chunk-vendors.5b404c1b.css

This file was deleted.

5 changes: 5 additions & 0 deletions backend/beastiary/webapp-dist/css/chunk-vendors.91bba9cc.css

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading

0 comments on commit 413da74

Please sign in to comment.