Fixed typo.
[pdm.git] / pdm-repl
CommitLineData
50f434d1 1#!/usr/bin/python3
37ee55d2
FT
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)
64f81f01
FT
17try:
18 cl = pdm.cli.replclient(args[0])
19except Exception as e:
20 sys.stderr.write("%s: %s\n" % (args[0], e))
21 sys.exit(1)
37ee55d2
FT
22
23buf = ""
24while True:
25 try:
26 if buf != "":
afd9f04c 27 line = input(" ")
37ee55d2 28 else:
afd9f04c 29 line = input("% ")
37ee55d2
FT
30 except EOFError:
31 break
32 if line == "":
33 sys.stdout.write(cl.run(buf))
34 buf = ""
35 else:
36 if buf == "":
37 try:
38 compile(line, "Nought", "eval")
39 except:
40 pass
41 else:
42 sys.stdout.write(cl.run(line))
43 continue
44 buf += line + "\n"