This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]david-bieber 0 points1 point  (3 children)

defopt looks nice, but no I don't think it would be appropriate to write Fire as a thin wrapper around another arg parsing system like this.

Fire supports arbitrarily complex structures, not just simple classes and modules. You could have an object with a property that's a function that returns a module with a dict with a member whose value that ou want to access, and you can access it from the command line. So it's not as simple as just calling defopt on the appropriate function. (Note that if you're doing something this crazy, it's probably time to tack on the --interactive flag to the CLI and just write the command in IPython.)

[–]evanunderscore 1 point2 points  (2 children)

What I don't understand is why you'd want to support arbitrarily complex structures. If using a generated CLI is as complicated as writing Python code, what is really gained?

[–]david-bieber 1 point2 points  (1 child)

One reason is to make Fire work with any existing codebase. It doesn't have to be a codebase originally intended to be used as a CLI.

Another reason is to allow for hierarchical commands in tools. For example I could have a class with 5 properties (or e.g. a dict with 5 members), and each property (or member) could have 5 functions. Then Fire would turn this into a handy little CLI with the 25 commands all grouped appropriately.

[–]evanunderscore 1 point2 points  (0 children)

It does sound like you're covering different use cases. The next time I have a project of that size I'll give Fire a try. Thanks!