fix optional arg for speckle token

This commit is contained in:
Gergő Jedlicska
2023-08-30 14:28:37 +02:00
parent 8543a6e68d
commit 7d7d6666d0
2 changed files with 45 additions and 9 deletions
+10 -2
View File
@@ -2,10 +2,18 @@ import typer
import os
from speckle_project_data import SpeckleProjectData
from automate_function import FunctionInputs, automate_function
from typing_extensions import Annotated
from typing import Optional
def main(speckle_project_data: str, function_inputs: str, speckle_token: str = ""):
speckle_token = speckle_token if speckle_token else os.environ.get("SPECKLE_TOKEN")
def main(
speckle_project_data: str,
function_inputs: str,
speckle_token: Annotated[Optional[str], typer.Argument()] = None,
):
speckle_token = (
speckle_token if speckle_token else os.environ.get("SPECKLE_TOKEN", None)
)
if not speckle_token:
raise ValueError("The supplied speckle token is not valid")