diff --git a/pyproject.toml b/pyproject.toml index 75dbfcf..95d3c10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,9 +27,7 @@ classifiers = [ "Programming Language :: Python :: 3.13", ] keywords = ["virtual", "env", "venv", "virtualenv", "environment", "poetry", "pipenv", "pdm"] -dependencies = [ - "platformdirs" -] +dependencies = ["platformdirs", "typer"] [project.urls] Homepage = "https://github.com/AlexMili/isVirtual" diff --git a/src/cli.py b/src/cli.py new file mode 100644 index 0000000..53ee1f1 --- /dev/null +++ b/src/cli.py @@ -0,0 +1,29 @@ +import typer +from typing_extensions import Annotated + +from . import check_dir, is_virtual_env + + +app = typer.Typer(add_completion=False) + + +@app.command(help="Check if you are currently in a virtual env") +def check() -> None: + if is_virtual_env() is True: + print("Yes") + else: + print("No") + + +@app.command(help="Scan if the given directory is linked to a virtual env") +def linked( + path: Annotated[ + str, + typer.Argument(), + ] = ".", +) -> None: + print(path) + if check_dir(path) is True: + print("Yes") + else: + print("Virtual environment not found") diff --git a/src/main.py b/src/main.py index ae20345..942226f 100644 --- a/src/main.py +++ b/src/main.py @@ -201,10 +201,3 @@ def generate_env_name(name: str, cwd: str) -> str: h_bytes = hashlib.sha256(_encode(normalized_cwd)).digest() h_str = base64.urlsafe_b64encode(h_bytes).decode()[:8] return f"{sanitized_name}-{h_str}" - - -def is_virtual_cli() -> None: - if is_virtual(): - print("Yes") - else: - print("No")