Merge pull request #2 from k-eex/master

support for startup commands from ~/.pronsolerc 
This adds support for an alias command
master
kliment 2011-06-01 07:06:38 -07:00
commit 0c5ae5e6b9
2 changed files with 12 additions and 0 deletions

5
.pronsolerc Normal file
View File

@ -0,0 +1,5 @@
# Sample .pronsolerc file - copy this into your home directory
!self.do_alias = lambda aarg,self=self: setattr(self,"do_"+aarg.split()[0],lambda arg,self=self,a=aarg.split(None,1)[1]:self.onecmd(" ".join((a,arg))))
alias up move Z 10
alias loud !self.loud = 1
alias quiet !self.loud = 0

View File

@ -74,6 +74,13 @@ class pronsole(cmd.Cmd):
cmd.Cmd.postloop(self)
def preloop(self):
try:
with open(os.path.join(os.path.expanduser("~"),".pronsolerc")) as rc:
for rc_cmd in rc:
if rc_cmd.lstrip()[0] != "#":
self.onecmd(rc_cmd.rstrip(r"\r\n"))
except IOError:
pass
print "Welcome to the printer console! Type \"help\" for a list of available commands."
cmd.Cmd.preloop(self)