3 ms·
Not diminishing, just making sure I understand right after looking at the readme. Is this equivalent to having all of those commands be subcommands, except you
by travisjungroth 4y ago
Not diminishing, just making sure I understand right after looking at the readme. Is this equivalent to having all of those commands be subcommands, except you call the outer one once and then you’re dropped into a context where you don’t have to call the outer one again until you exit? Useful for commands you tend to hammer on, like any hosting CLI.
It seems like you’re not carrying any state, which is generally a great place to be. It might be nice to be able to explicitly pass in the return value from the last call as a argument to the next call. The calculator example is an obvious case. I’ve also wanted that when using many CLIs. It’s sort of like an after-the-fact pipe. If I create a server and the want to attach a database to a server, it seems like “server I created two seconds ago” is a good default. It’d be fine if I had to type _ or whatever.
- Aperocky 4y agoThat's a very good point, I think right now it would be for the custom implementation to carry state, i.e. load the answer to the last question in self.result, and go on and do anything with the stored value from there. argparse also basically give you the ability to utilize one command subcommand to do anything, but sometimes having the top level command freedom is nice.