Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Custom Pythonista Command Line Interface
-
I have been working on creating my own command line interface with Python. I am now tweaking it to make it to make different things, like a chatbot.
The script is easily customizable. I have an even shorter basic version:
# -*- coding: utf -*- # A most basic python command line interface (Customizable!) # By the tutorial Doctor # Saturday September 05, 2015 username = 'Tutorial Doctor' # Main Loop #------------------------------------------------------------------------------ def Main(): displayCommands() running=True while running: command=raw_input('Type a command %s:'%username).upper() if command == 'END': print 'Terminated...' return False prompt(command) #------------------------------------------------------------------------------ # The Shell #------------------------------------------------------------------------------ def prompt(c): eraseConsole(c) #------------------------------------------------------------------------------ # Functions (Your functions here) #------------------------------------------------------------------------------ import console def displayCommands(): # Print your custom commands here print('Console: end,erase') # If multiple commands mean the same thing, use "in" def eraseConsole(c): if c in ['...','ER','ERASE','cls','clear']: # All 5 commands will erase print('o') cls # Call your functions under the prompt() function #------------------------------------------------------------------------------ Main()
I am wondering about making a UI version. But I am wondering what type of commands would people like to see for Pythonista. If you look at the command line version, it has options like creating files and directories and such.
-
Check out the cmd module. It makes it very easy to write interactive command-line programs.
-
You might want to take a look at stash. It is now pretty modular, so one could use just the terminal for their own chatbot, or you could write programs intended to be run from within stash (such as chatbots, etc), which then lets you take advantage of things like custom keyboards or custom commands.
-
-
I will check out both cmd and stash (I actually knew about cmd, but it wasn't as user friendly as I wanted it to be).
I could use libraries as models though. Still wondering what types of commands would be useful. I have one that creates a file in the current directory. Thinking about using the Twitter module once 1.6 is released. Perhaps some matplotlib stuff, or numpy. Etc.