Commit | Line | Data |
---|---|---|
37ee55d2 FT |
1 | #!/usr/bin/python |
2 | ||
3 | import sys, getopt, readline | |
4 | import pdm.cli | |
5 | ||
6 | def usage(out): | |
7 | out.write("usage: pdm-repl [-h] SOCKET\n") | |
8 | ||
9 | opts, args = getopt.getopt(sys.argv[1:], "h") | |
10 | for o, a in opts: | |
11 | if o == "-h": | |
12 | usage(sys.stdout) | |
13 | sys.exit(0) | |
14 | if len(args) < 1: | |
15 | usage(sys.stderr) | |
16 | sys.exit(1) | |
17 | cl = pdm.cli.replclient(args[0]) | |
18 | ||
19 | buf = "" | |
20 | while True: | |
21 | try: | |
22 | if buf != "": | |
afd9f04c | 23 | line = input(" ") |
37ee55d2 | 24 | else: |
afd9f04c | 25 | line = input("% ") |
37ee55d2 FT |
26 | except EOFError: |
27 | break | |
28 | if line == "": | |
29 | sys.stdout.write(cl.run(buf)) | |
30 | buf = "" | |
31 | else: | |
32 | if buf == "": | |
33 | try: | |
34 | compile(line, "Nought", "eval") | |
35 | except: | |
36 | pass | |
37 | else: | |
38 | sys.stdout.write(cl.run(line)) | |
39 | continue | |
40 | buf += line + "\n" |