-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
CLI routing not working with extend_api()
#744
Labels
Comments
akaihola
pushed a commit
to akaihola/hug
that referenced
this issue
Mar 18, 2019
Strangely, the test in #745 doesn't fail even though doing the same with the following main program fails to include the new command in the API:
import hug
import module_fake_http_and_cli
API = hug.API(__name__)
@hug.extend_api('/api', API)
def extend_with():
return [module_fake_http_and_cli]
if __name__ == '__main__':
API.cli() $ python tests/module_cli_main.py
__main__
Available Commands:
-
$ python tests/module_cli_main.py made_up_go
__main__
Available Commands:
-
|
This is the (clumsy) work-around I'm using currently: import hug
from module_fake_http_and_cli import made_up_go
from another_module import another_command
COMMANDS = [made_up_go, another_command]
API = hug.API(__name__)
commands = API.cli.commands
for command in COMMANDS:
commands.update(command.interface.api._cli.commands)
@hug.extend_api('/api', API)
def extend_with():
return {command.__module__ for command in COMMANDS}
if __name__ == '__main__':
API.cli() |
timothycrosley
added a commit
that referenced
this issue
Mar 19, 2019
Add unit test for `extend_api()` with CLI commands (#744)
Merged
Should be resolved by: https://github.com/timothycrosley/hug/pull/747/files which is slated for the next release. Thanks! ~Timothy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As Eduardo Marinho reported on Stack Overflow:
(ping @dudez20 in case you're the same guy here on GitHub)
The text was updated successfully, but these errors were encountered: