Skip to content

Commit

Permalink
Add: the --version option.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjones1 committed Feb 7, 2022
1 parent 1e2c3f0 commit 9fd13ab
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion CodeChat_Server/CodeChat_Server/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import subprocess
import threading
from time import sleep
from typing import List, Sequence
from typing import List, Optional, Sequence

# Third-party imports
# -------------------
Expand Down Expand Up @@ -172,6 +172,23 @@ def shutdown(self) -> None:
# =============
app = typer.Typer()


# Add a ``--version`` optional globally.
def version_callback(value: bool) -> None:
if value:
typer.echo(f"The CodeChat Server, v.{__version__}")
sys.exit(0)


@app.callback()
def common(
version: Optional[bool] = typer.Option(
None, "--version", callback=version_callback, is_eager=True
),
) -> None:
pass


INSECURE_HELP = "Setting this True allows the webserver and websocket to accept connections from any address (they bind to 0.0.0.0). This is extremely dangerous and insecure. If enabled, these ports should be firewalled and carefully protected. This mode is offered to support remote development using Visual Studio Code, which provides a secure (SSH-based) connection. The default value of False allows only connections from the machine this program runs on."


Expand Down

0 comments on commit 9fd13ab

Please sign in to comment.