Commit 0c5ae5e6 authored by kliment's avatar kliment

Merge pull request #2 from k-eex/master

support for startup commands from ~/.pronsolerc 
This adds support for an alias command
parents 36736e31 69e23def
# 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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment