Custom Interactive Shell with AutoComplete
Asked Answered
F

2

10

I have been tasked to create an interactive shell to be embedded in python, such that, when called from the command line it will be dropped into that shell. Can anyone recommend me a library that does this?

I would need the ability to create custom words, "actions," so when the user types those words, my program can execute the correct function that I have created. I would also like the ability of auto complete / tab complete on the custom words I created.

Example:

$ python myapplication.py
$ myapp> 
$ myapp> help
   ... prints the help menu
$ myapp> run service blah
   .. service blah runs ...
$ myapp> exit
$ 
Forty answered 6/10, 2014 at 23:9 Comment(2)
What a bout a module like this for inspiration?Gandzha
Good to hear :) I added my answer as an answer, in case anyone else searches this.Gandzha
G
9

Try this cmd module. It's designed for that purpose.

Gandzha answered 7/10, 2014 at 0:30 Comment(0)
S
5

Python Prompt toolkit is a very good module to use when you want to make a fully featured interactive shell. It comes with all the needed features like :

  • Auto-complete (with visual dropdowns)
  • Command history and search
  • Works cross-platform
Selina answered 18/9, 2018 at 23:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.