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

Push function name and meta of sub-command into function #670

Open
TomFreudenberg opened this issue Jan 20, 2024 · 2 comments
Open

Push function name and meta of sub-command into function #670

TomFreudenberg opened this issue Jan 20, 2024 · 2 comments

Comments

@TomFreudenberg
Copy link
Contributor

Hi, I wanted to re-use especially the given help information from @ex decorator in some log infos of command:

@ex(help="This is the helpline")
def mycommand(self):
    print(...myhelp...)

As I checked the code, all is already prepared at the lines:

elif hasattr(contr, func_name):
func = getattr(contr, func_name)
return func()

but the information not pushed forward to the function.

810      return func(func_name, func.__cement_meta__)

That would make things much easier.

Actually, I solved that by:

@ex(help="This is the helpline")
def mycommand(self):
    func = getattr(self, self.app.pargs.__dispatch__.split('.')[1])
    print(func.__cement_meta__['parser_options']['help'])

This is a bit anoying, would prefer:

@ex(help="This is the helpline")
def mycommand(self, func_name, func_meta):
    print(func_meta['parser_options']['help'])

What do you think about that?

@TomFreudenberg
Copy link
Contributor Author

By the way - let me say that I am totally impressed about Cement. Very well done and great Interfaces and Abstracts. I used it some years ago and now for a new project again. I am very happy that I have choose it again. Thanks for your work!

@TomFreudenberg
Copy link
Contributor Author

I created a lambda which works as well

subcmdmeta = lambda a : getattr(a, a.app.pargs.__dispatch__.split('.')[1]).__cement_meta__

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

No branches or pull requests

1 participant