New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command-line interfaces don't handle keywords #873
Comments
Currently you have no default values for the parameters, making them positional instead of keyword arguments:
If you modify the code to have default values then you can address them by keywords: import hug
def hello_world(name1: str = "First", name2: str = "Second"):
return f"Hello {name1} and {name2}"
if __name__ == '__main__':
api = hug.API(__name__)
hello_world = hug.cli('hello_world', api=api)(hello_world)
api.cli()
In this case I think the primary confusion for this issue is that hug is ignoring keywords it does not recognize instead of warning the user about unexpected arguments. |
@Peter200lx sure, I've noticed that. However that's not expected behavior. Possible options are
|
General CLI patterns doesn't really agree with the first option, positional arguments and keyword arguments are two very different things. In the last line of my previous comment I agree that it is bad behavior that HUG ignores keyword arguments that it doesn't recognize. You can see this as you can pass any keyword argument:
I believe the bug here is that hug is ignoring CLI options it doesn't specifically recognize. |
Contents for
testhug.py
Keywords are ignored. I see CLI is not in priority, but if that's expected behavior, this should be documented well (one wouldn't expect CLI to behave like this).
Liked concept a lot though.
The text was updated successfully, but these errors were encountered: