title: Python CLI Keeps Performing the Same Command?
body: <p>I'm trying to create a command line that will allow a user to perform various functions.
  For example, if I type "scriptrun" into the terminal, I want it to run a function from another .py file, and then return to the terminal (->>).
  For some reason, if I type "scriptrun", it will run properly, but then if I hit "enter" again, it will cause the command to be run again.  I'm basing it off a Turtle CLI that I found.  After I enter help, I want it to show the list of help topics only once, and then if I keep hitting enter, it will just show the terminal, but the following is happening!:</p>
  
  <p>(Terminal) help</p>
  
  <h1>Documented commands (type help ):</h1>
  
  <p>bye     color    goto     help  left      position  reset  scriptrun
  circle  forward  heading  home  playback  record    right  undo     </p>
  
  <p>(Terminal) [Here i just hit enter, but below you can see it's calling the help function again!]</p>
  
  <h1>Documented commands (type help ):</h1>
  
  <p>bye     color    goto     help  left      position  reset  scriptrun
  circle  forward  heading  home  playback  record    right  undo     </p>
  
  <p>(Terminal) </p>
  
  <p>Below is the sample code that I am trying to figure out the solution to:</p>
  
  <pre><code>import cmd, sys
  from turtle import *
  from orion_package import *
  
  class TurtleShell(cmd.Cmd):
      intro = 'Welcome to the turtle shell.   Type help or ? to list commands.\n'
      prompt = '(Terminal) '
      file = None
  
  
      # ----- basic turtle commands -----
      def do_forward(self, arg):
          'Move the turtle forward by the specified distance:  FORWARD 10'
          forward(*parse(arg))
      def do_right(self, arg):
          'Turn turtle right by given number of degrees:  RIGHT 20'
          right(*parse(arg))
      def do_left(self, arg):
          'Turn turtle left by given number of degrees:  LEFT 90'
          left(*parse(arg))
      def do_goto(self, arg):
          'Move turtle to an absolute position with changing orientation.  GOTO 100 200'
          goto(*parse(arg))
      def do_home(self, arg):
          'Return turtle to the home postion:  HOME'
          home()
      def do_circle(self, arg):
          'Draw circle with given radius an options extent and steps:  CIRCLE 50'
          circle(*parse(arg))
      def do_position(self, arg):
          'Print the current turle position:  POSITION'
          print('Current position is %d %d\n' % position())
      def do_heading(self, arg):
          'Print the current turle heading in degrees:  HEADING'
          print('Current heading is %d\n' % (heading(),))
      def do_color(self, arg):
          'Set the color:  COLOR BLUE'
          color(arg.lower())
      def do_undo(self, arg):
          'Undo (repeatedly) the last turtle action(s):  UNDO'
      def do_reset(self, arg):
          'Clear the screen and return turtle to center:  RESET'
          reset()
      def do_bye(self, arg):
          'Stop recording, close the turtle window, and exit:  BYE'
          print('Thank you for using Turtle')
          self.close()
          bye()
          return True
  
  
      # ----- record and playback -----
      def do_record(self, arg):
          'Save future commands to filename:  RECORD rose.cmd'
          self.file = open(arg, 'w')
      def do_playback(self, arg):
          'Playback commands from a file:  PLAYBACK rose.cmd'
          self.close()
          with open(arg) as f:
              self.cmdqueue.extend(f.read().splitlines())
      def precmd(self, line):
          line = line.lower()
          if self.file and 'playback' not in line:
              print(line, file=self.file)
          return line
      def close(self):
          if self.file:
              self.file.close()
              self.file = None
  
      def do_scriptrun(self, arg):
          'Run the script: SCRIPTRUN'
          print("Let's run this thing!  :)")
          scriptrun()
  
  
  def parse(arg):
      'Convert a series of zero or more numbers to an argument tuple'
      return tuple(map(int, arg.split()))
  
  
  if __name__ == '__main__':
      TurtleShell().cmdloop()
  </code></pre>
  
  <p>Any help or advice for a solution is greatly appreciated!  Thank you! :)</p>