-
Notifications
You must be signed in to change notification settings - Fork 116
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
Emphasize development and debug utility of ipy command #979
Comments
I found some documentation on
|
Set |
Oh 🤦 , I missed the information in your first comment and at the top of the page for embedded_python_shells Maybe an example under the class PyApp(Cmd):
def __init__(self):
"""Initialize cmd2 application with ipy enabled."""
super().__init__(use_ipython=True)
self.self_in_py = True # Note: when enabled, user can access `self` in ipy shell, which is not recommended for production |
@kmvanbrunt What other changes do you typically make in your developer mode? |
In developer mode, I typically do the following:
If not in developer mode:
|
@kmvanbrunt Do you think that is a generic enough functionality that we should add it into cmd2, perhaps as an opt-in feature supported by an optional flag provided to the initializer? |
@kmvanbrunt Please tell me more how you enable 'developer mode'. Is this something that you toggle with a general command after release or do you hide it somewhere and only use it when needed. So normal users could be developers if they wanted. This sounds like a good idea for my cmd2 templates. |
@jayrod I just make developer mode a command line option when opening the app. I'm not worried if my users are aware of it, but other applications may want to hide it depending on the intended users. |
I've been using cmd2 for a long time and it is a great framework to begin any CLI application, the examples are great for familiarization but more complicated things like "developer mode" are a bit more difficult to flesh out. I think adding a developer mode to my cookiecutter template would mean all would get this functionality by default. I just want to make sure I do it the right way ;) |
Maybe we can flesh out what "developer mode" really means. I know why self_in_py is used for but why is that a bad thing for normal user mode? I also saw that there was a nice auto-doc script in the example folder to help spit out help documentation for all commands but it required self_in_py mode. Perhaps developer mode could auto set everything and offer this sort of command. Are there other developer only commands settings? |
I like the idea of adding a "developer" mode option to the cookie cutter template and possibly adding some kind of support for it to At a minimum, during development of
The first two allow me to do complete realtime troubleshooting of application state within an IPython shell embedded in the application. The last allows me to see a full traceback if/when there is an unhandled exception. Often I have altered at least the I could see adding an optional argument to I could also see taking it to the next level and accepting a @kmvanbrunt Any thoughts? |
@kmvanbrunt could you perhaps share a snippet of how you enable dev mode from the command line.. create a do_dev_mode function that "toggles" settings on and off? |
I'm pretty sure @kmvanbrunt uses We used to have a good example showing how to do this and I'm not sure what happened to it. The decorator_example.py example still shows the basics of how to do it - just not in a way that is useful, but the important mechanics are there. So I think in his app, he would launch his CLI like so to launch it in dev mode: % ./custom_cmd2_app.py --dev |
I like the concept of putting this in the basic oookiecutter template: jayrod/cookiecutter-python-cmd2#10 We can probably also update our documentation a little to emphasize just how darn useful |
I've got some time and now some experience but I admit I have not used ipy or even debug during my development of cmd2 apps. I played around with So my question is what use cases are really useful for ipython usage? when I run into issues I simply set a debug point inside of a command and create a command to duplicate the issue. ex. app.py "command1" "command2 -with args" "quit" |
In both These shells offer a lot for debugging. I commonly do the following operations:
I also use |
The utility of the optional
ipy
command combined withself.self_in_py = True
for developers is truly phenomenal. We don't do these amazing features justice in our documentation and I'm not sure how discoverable they are for newcmd2
developers. These features open the door to an enhanced development experience that allows easy experimenting as well as the ability to do some after-the-fact debugging when things don't behave like you think they should.We should add a section on "Developer Tips" or something like that to our documentation.
The text was updated successfully, but these errors were encountered: