pythonpython-cmd

Python application with both interactive and inline mode


I am trying to create a Python command-line app, which supports both interactive (currently using Cmd) and inline modes (like Python's python -c). Is there a good way to do it without duplicating the 'line parsing' code?


Solution

  • Use the Cmd.onecmd method:

    Interpret the argument as though it had been typed in response to the prompt.