Add some more documentation
This commit is contained in:
parent
5565f0c4ef
commit
490c9f5900
19
main.py
19
main.py
@ -7,6 +7,8 @@ import os
|
||||
import os.path
|
||||
import shlex
|
||||
|
||||
# Load all of the commands in the path into the global namespace as raw
|
||||
# commands.
|
||||
for path in os.environ['PATH'].split(':'):
|
||||
if os.path.exists(path):
|
||||
binaries = os.listdir(path)
|
||||
@ -34,18 +36,23 @@ def parse_cmd(potential_cmd):
|
||||
return "{0}({1})".format(cmd_name,str(args))
|
||||
|
||||
|
||||
def parse_cmds(raw):
|
||||
potential_cmds = raw.split('|')
|
||||
def parse_cmds(raw_input_line):
|
||||
"""Parses command objects out of a single | separated string"""
|
||||
potential_cmds = raw_input_line.split('|')
|
||||
cmds = [parse_cmd(cmd) for cmd in potential_cmds]
|
||||
return cmds
|
||||
|
||||
|
||||
def handle_input(prompt=""):
|
||||
raw = input(prompt)
|
||||
if raw[0] == '>':
|
||||
return raw[1:]
|
||||
"""Gets a single line of input for the REPL, and returns some valid
|
||||
Python for the rest of the REPL to evaluate. It's the "R" in REPL.
|
||||
If the line begins with ">", we just strip it and evaluate as valid
|
||||
Python."""
|
||||
raw_input_line = input(prompt)
|
||||
if raw_input_line[0] == '>':
|
||||
return raw_input_line[1:]
|
||||
else:
|
||||
cmds = parse_cmds(raw)
|
||||
cmds = parse_cmds(raw_input_line)
|
||||
cmds.append("Printer()")
|
||||
mangled_input = cmds[0]
|
||||
for cmd in cmds[1:]:
|
||||
|
Reference in New Issue
Block a user