Skip to content
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 help message seems broken when using subcommands #875

Open
hoshiyosan opened this issue Oct 24, 2020 · 0 comments · May be fixed by #876
Open

CLI help message seems broken when using subcommands #875

hoshiyosan opened this issue Oct 24, 2020 · 0 comments · May be fixed by #876

Comments

@hoshiyosan
Copy link

CLI help message seems broken when using subcommands

Example for the following code

Content of manage.py

"""
Manage database objects
Usage:  manage [-h] COMMAND [options]
"""

import hug


# Create user api
users_api = hug.API(name='users', doc='Manage users')

@hug.object(name='user', api=users_api)
class UsersCLI:
    @staticmethod
    @hug.object.cli
    def add(name:hug.types.text):
        """Create user"""

    @staticmethod
    @hug.object.cli
    def rm(id:hug.types.number):
        """Remove user with given id"""


# Create permission api
permissions_api = hug.API(name='permissions', doc="Manage users permissions")

@hug.object(name='permission', api=permissions_api)
class PermissionCLI:
    @staticmethod
    @hug.object.cli
    def add(name:hug.types.text):
        """Create permission"""

    @staticmethod
    @hug.object.cli
    def attach(uid:hug.types.number, pid:hug.types.number):
        """Give permission {pid} to user {uid}"""


def main():
    api = hug.API(name='manage', doc=__doc__)
    api.extend(users_api, sub_command='users')
    api.extend(permissions_api, sub_command='permissions')
    api.cli()


if __name__ == '__main__':
    main()

Actual behavior

Currently doing...

python -m manage

...results in :

Manage database objects
Usage:  manage [-h] COMMAND [options]


Available Commands:

 - users: Manage users  Available Commands:   - add: Create user  - rm: Remove...
 - permissions: Manage users permissions  Available Commands:   - add: Create...

Proposed behavior

It should rather be:

Manage database objects
Usage:  manage [-h] COMMAND [options]


Available Commands:

 - users         Manage users
 - permissions   Manage users permissions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant