+ statusTxt = (" ".join(options['extra_args'])
+ if options['extra_args']
+ else str(input("message: ")))
+ twitter.statuses.update(status=statusTxt)
+
+class TwitterShell(Action):
+
+ def render_prompt(self, prompt):
+ '''Parses the `prompt` string and returns the rendered version'''
+ prompt = prompt.strip("'").replace("\\'","'")
+ for colour in ansi.COLOURS_NAMED:
+ if '[%s]' %(colour) in prompt:
+ prompt = prompt.replace(
+ '[%s]' %(colour), ansi.cmdColourNamed(colour))
+ prompt = prompt.replace('[R]', ansi.cmdReset())
+ return prompt
+
+ def __call__(self, twitter, options):
+ prompt = self.render_prompt(options.get('prompt', 'twitter> '))
+ while True:
+ options['action'] = ""
+ try:
+ args = input(prompt).split()
+ parse_args(args, options)
+ if not options['action']:
+ continue
+ elif options['action'] == 'exit':
+ raise SystemExit(0)
+ elif options['action'] == 'shell':
+ print('Sorry Xzibit does not work here!', file=sys.stderr)
+ continue
+ elif options['action'] == 'help':
+ print('''\ntwitter> `action`\n
+ The Shell Accepts all the command line actions along with:
+
+ exit Leave the twitter shell (^D may also be used)
+
+ Full CMD Line help is appended below for your convinience.''', file=sys.stderr)
+ Action()(twitter, options)
+ options['action'] = ''
+ except NoSuchActionError as e:
+ print(e, file=sys.stderr)
+ except KeyboardInterrupt:
+ print('\n[Keyboard Interrupt]', file=sys.stderr)
+ except EOFError:
+ print(file=sys.stderr)
+ leaving = self.ask(subject='Leave')
+ if not leaving:
+ print('Excellent!', file=sys.stderr)
+ else:
+ raise SystemExit(0)
+
+class PythonPromptAction(Action):
+ def __call__(self, twitter, options):
+ try:
+ while True:
+ smrt_input(globals(), locals())
+ except EOFError:
+ pass