Include perfclient in pdm.cli's exports.
[pdm.git] / pdm-repl
CommitLineData
37ee55d2
FT
1#!/usr/bin/python
2
3import sys, getopt, readline
4import pdm.cli
5
6def usage(out):
7 out.write("usage: pdm-repl [-h] SOCKET\n")
8
9opts, args = getopt.getopt(sys.argv[1:], "h")
10for o, a in opts:
11 if o == "-h":
12 usage(sys.stdout)
13 sys.exit(0)
14if len(args) < 1:
15 usage(sys.stderr)
16 sys.exit(1)
17cl = pdm.cli.replclient(args[0])
18
19buf = ""
20while True:
21 try:
22 if buf != "":
23 line = raw_input(" ")
24 else:
25 line = raw_input("% ")
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"