Commits

Michał Górny  committed 09de4ec

Support running an IPython shell.

  • Participants
  • Parent commits c487024

Comments (0)

Files changed (1)

File gentoopm/querycli.py

 				return 1
 			print(r.path)
 
+	class shell(PMQueryCommand):
+		"""
+		Run a Python shell with current PM selected.
+		"""
+		def __call__(self, pm, args):
+			try:
+				from IPython import embed
+			except ImportError:
+				self._arg.error('IPython >= 0.11 required for shell')
+				return 1
+
+			welc = "The %s PM is now available as 'pm' object." % pm.name
+			embed(banner2 = welc)
+
 	def __iter__(self):
 		for k in dir(self):
 			if k.startswith('_'):