Merge pull request #2 from k-eex/master
support for startup commands from ~/.pronsolerc This adds support for an alias commandmaster
commit
0c5ae5e6b9
|
@ -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
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue