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

components-extension #273

Open
stroupbslayen opened this issue Jul 17, 2020 · 0 comments
Open

components-extension #273

stroupbslayen opened this issue Jul 17, 2020 · 0 comments

Comments

@stroupbslayen
Copy link

@stroupbslayen stroupbslayen commented Jul 17, 2020

Hi,

I just got introduced to this project and am really liking it so far, it's got a lot of potential, is relatively simple to understand and get up and working for something simple. Organization was a problem I ran into pretty quickly though and expanding into a larger project the process didn't really click for me for how to to get stuff working the way I would have liked. To solve this I forked the project and put together a components-extension. It could still use some documentation but it seems to be working with what I've tested.

Basically using decorators to help the flow of creating different commands and groups for an app like this:

import fire
from fire.ext import components

component = components.Component()

# create a new group the belongs to the component
basic_math = component.new_group("Basic Math")

# add a command to a group
@basic_math.command(name="add")
def adder(a, b):
    return a + b

if __name__ == "__main__":
    fire.Fire(component.build(), name="Example")

And you can run

python file.py Basic_Math add 3 4
>>> 7

It might not be super useful for very simple apps but when expanding I think it makes things very easy to work with.

It's not working directly with fire though, so I'm not sure if it's something that should be implemented with it or just kept separate but I thought I'd mention it anyways.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.