Extensible python-based shell/CLI with built-in tab completion, command backlog, and help function for your custom commands.
Download repository files and run python shell.py
. Start a little dialog (using TAB and arrow keys) to get a feeling for the behavior of the shell:
Welcome to simple python shell!
> [hit TAB]
command_one command_three command_two create_command help
> help
Documented commands (type help <topic>):
========================================
command_one command_three command_two create_command help
> com[hit TAB]
command_one command_two
> command_one
executing command_one
> help create_command
creates a new shell command with the passed name. command names should be lowercase words, separated by underscrores.
> create_command command_three
creating command class "CommandThree" in module ".../extensible-py-shell/commands/command_three.py"
Extending the shell is straightforward: provide a new command class in a corresponding module in directory extensible-py-shell/commands
, add the command description in the docstring of the constructor, and implement the execute
method. There's a simple naming rule to be followed, though: use lowercase words seperated by underscores for the module name, use the same words in CamelCase for the command class. See the existing commands for reference. Then restart the shell and your command should be integrated
The program was developed and tested using Python 3.6.2. I'd expect it to run with Python 2.7 or 3.3. However, if you have trouble running it with your python version, feel free to contact me or post a comment.
This project is licensed under the MIT License - see the LICENSE.md file for details
Hat tip to Python's Cmd
class