Hi @BrianPugh!
Kudos for continuing to improve Cyclopts. I now asked my team to migrate a mid-sized project from Click to Cyclopts as an experiment. Overall it went pretty smoothly, though one persistent nuisance is that, in order to alias a parameter, you need to do the whole "Annotated" magic.
Example:
part: Optional[
Annotated[
str,
cyclopts.Parameter(
alias="-p", help="Specify the FPGA part number"
),
]
] = None,
Now I can see that for help, Cyclopts seems to support docstrings (great!). But there is no other way to submit the "-p" alias. I was thinking if solving that problem wouldn't be super awesome as it would let us avoid the whole Annotated nesting and the cyclopts.Parameter etc etc.
Three ways I see to solve this:
@app.command
def deploy(
env: Literal["dev", "staging", "prod"],
replicas: int | Literal["default", "performance"] = "default",
):
"""Deploy code to an environment.
Parameters
----------
env (e)
Environment to deploy to.
replicas (r)
Number of workers to spin up.
"""
if replicas == "default":
replicas = 10
elif replicas == "performance":
replicas = 20
print(f"Deploying to {env} with {replicas} replicas.")
I think having help is important, and the only way to not have Annotated and have help is to have docstrings. So some sort of docstrings based solution would work best for our use case, I think. But then again, having the "mark command as autoaliasing parameters" would probably be OK too! (or some other solution).
The downside of an explicit "alias" decorator would be that, including docstrings, you would end up listing parameters three times, ouch.
What do you think?
Hi @BrianPugh!
Kudos for continuing to improve Cyclopts. I now asked my team to migrate a mid-sized project from Click to Cyclopts as an experiment. Overall it went pretty smoothly, though one persistent nuisance is that, in order to alias a parameter, you need to do the whole "Annotated" magic.
Example:
Now I can see that for help, Cyclopts seems to support docstrings (great!). But there is no other way to submit the "-p" alias. I was thinking if solving that problem wouldn't be super awesome as it would let us avoid the whole Annotated nesting and the cyclopts.Parameter etc etc.
Three ways I see to solve this:
I think having help is important, and the only way to not have Annotated and have help is to have docstrings. So some sort of docstrings based solution would work best for our use case, I think. But then again, having the "mark command as autoaliasing parameters" would probably be OK too! (or some other solution).
The downside of an explicit "alias" decorator would be that, including docstrings, you would end up listing parameters three times, ouch.
What do you think?