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

contrib: Add a sample IPython shell with magic commands #359

Closed
wants to merge 1 commit into from

Conversation

brenns10
Copy link
Contributor

Here's the sample IPython shell code, edited down to be standalone. The docstring should contain everything you need to know, and here's a little demo:

image

Sadly, the "ERROR: root:Invalid alias" thing can't be avoided, unless you fully disable logging, which I didn't want to do. But as you can see, you get a pretty standard Ipython shell, with the ability to run custom commands as %command. And, if the command is not found in the globals, then you can actually run it as "command" without the prefix. And IPython always gives you a range of other magic commands, as well as shell command access with !.

The toy codebase I stripped it from actually had two CLIs:

  1. The IPython one shown here
  2. The standard drgn CLI, but with an added global: crash(). The crash() global swapped into a new CLI, which would allow you to execute the commands shown here, or swap back to the drgn CLI. I would have added all of the fun bash-isms and piping features of crash, but I ended up coming to the conclusion that reimplementing Crash on top of drgn didn't seem like a great use of my time.

That's why I didn't just write the commands as IPython magic class / magic functions. Also because I don't like the IPython magic API, but that's a separate story.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
@brenns10
Copy link
Contributor Author

brenns10 commented Nov 9, 2023

Cleaning up: #367 is better than this, closing.

@brenns10 brenns10 closed this Nov 9, 2023
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

Successfully merging this pull request may close these issues.

1 participant