summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2001-07-17 04:59:01 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2001-07-17 04:59:01 (GMT)
commit96d88422373ffb32aef75157647e0575a0471c03 (patch)
treed40708792792073d38740250f78b0c7cda03f8dc /Lib/idlelib
parent0eb4f3e99404c2646060089b5859dc2372f220c4 (diff)
downloadcpython-96d88422373ffb32aef75157647e0575a0471c03.zip
cpython-96d88422373ffb32aef75157647e0575a0471c03.tar.gz
cpython-96d88422373ffb32aef75157647e0575a0471c03.tar.bz2
Implement idle command interface as suggested by GvR [idle-dev] 16 July
**************** PyShell: Added functionality: usage: idle.py [-c command] [-d] [-i] [-r script] [-s] [-t title] [arg] ... idle file(s) (without options) edit the file(s) -c cmd run the command in a shell -d enable the debugger -i open an interactive shell -i file(s) open a shell and also an editor window for each file -r script run a file as a script in a shell -s run $IDLESTARTUP or $PYTHONSTARTUP before anything else -t title set title of shell window Remaining arguments are applied to the command (-c) or script (-r). ****************** idles: Removed the idles script, not needed ****************** idle: Removed the IdleConf references, not required anymore
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/PyShell.py41
-rwxr-xr-xLib/idlelib/idle10
-rwxr-xr-xLib/idlelib/idles13
3 files changed, 26 insertions, 38 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index cab7328..3fab3c2 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -709,17 +709,19 @@ class PseudoFile:
return 1
usage_msg = """\
-usage: idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
+usage: idle.py [-c command] [-d] [-i] [-r script] [-s] [-t title] [arg] ...
--c command run this command
--d enable debugger
--e edit mode; arguments are files to be edited
--s run $IDLESTARTUP or $PYTHONSTARTUP before anything else
--t title set title of shell window
+idle file(s) (without options) edit the file(s)
-When neither -c nor -e is used, and there are arguments, and the first
-argument is not '-', the first argument is run as a script. Remaining
-arguments are arguments to the script or to the command run by -c.
+-c cmd run the command in a shell
+-d enable the debugger
+-i open an interactive shell
+-i file(s) open a shell and also an editor window for each file
+-r script run a file as a script in a shell
+-s run $IDLESTARTUP or $PYTHONSTARTUP before anything else
+-t title set title of shell window
+
+Remaining arguments are applied to the command (-c) or script (-r).
"""
class usageError:
@@ -781,29 +783,34 @@ class main:
cmd = None
edit = 0
debug = 0
+ interactive = 0
+ script = None
startup = 0
try:
- opts, args = getopt.getopt(argv, "c:deist:")
+ opts, args = getopt.getopt(argv, "c:dir:st:")
except getopt.error, msg:
sys.stderr.write("Error: %s\n" % str(msg))
sys.stderr.write(usage_msg)
sys.exit(2)
for o, a in opts:
- noshell = 0
+ noshell = 0 # There are options, bring up a shell
if o == '-c':
cmd = a
if o == '-d':
debug = 1
- if o == '-e':
- edit = 1
+ if o == '-i':
+ interactive = 1
+ if o == '-r':
+ script = a
if o == '-s':
startup = 1
if o == '-t':
PyShell.shell_title = a
if noshell: edit=1
+ if interactive and args and args[0] != "-": edit = 1
for i in range(len(sys.path)):
sys.path[i] = os.path.abspath(sys.path[i])
@@ -860,9 +867,11 @@ class main:
shell.open_debugger()
if cmd:
interp.execsource(cmd)
- elif not edit and args and args[0] != "-":
- interp.execfile(args[0])
-
+ elif script:
+ if os.path.isfile(script):
+ interp.execfile(script)
+ else:
+ print "No script file: ", script
shell.begin()
self.idle()
diff --git a/Lib/idlelib/idle b/Lib/idlelib/idle
index 2a85497..8638a16 100755
--- a/Lib/idlelib/idle
+++ b/Lib/idlelib/idle
@@ -1,12 +1,4 @@
#! /usr/bin/env python
-import os
-import sys
-from idlelib import IdleConf
-
-idle_dir = os.path.dirname(IdleConf.__file__)
-IdleConf.load(idle_dir)
-
-# defer importing Pyshell until IdleConf is loaded
-from idlelib import PyShell
+import PyShell
PyShell.main()
diff --git a/Lib/idlelib/idles b/Lib/idlelib/idles
deleted file mode 100755
index b2233b7..0000000
--- a/Lib/idlelib/idles
+++ /dev/null
@@ -1,13 +0,0 @@
-#! /usr/bin/env python
-
-import os
-import sys
-from idlelib import IdleConf
-
-idle_dir = os.path.dirname(IdleConf.__file__)
-IdleConf.load(idle_dir)
-
-# defer importing Pyshell until IdleConf is loaded
-from idlelib import PyShell
-# open a shell instead of an editor window
-PyShell.main(0)