Skip to content

Commit

Permalink
Add more CLI options
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMili committed May 30, 2024
1 parent 78dea18 commit a3ef8eb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 29 additions & 0 deletions src/cli.py
Original file line number Diff line number Diff line change
@@ -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")
7 changes: 0 additions & 7 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit a3ef8eb

Please sign in to comment.