1

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?

Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
Elad Weiss
  • 3,662
  • 3
  • 22
  • 50

1 Answers1

2

Use the Cmd.onecmd method:

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

Vasiliy Faronov
  • 11,840
  • 2
  • 38
  • 49