This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cmd.py: add instance-specific stdin/out
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: anthonybaxter Nosy List: anthonybaxter, gvanrossum, loewis
Priority: normal Keywords: patch

Created on 2002-05-21 05:45 by anthonybaxter, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cmd.diff anthonybaxter, 2002-06-06 01:20 really, truly a patch this time. really
Messages (7)
msg40060 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2002-05-21 05:45
The following patch adds stdin, stdout as optional
arguments to the cmd.Cmd constructor (defaulting to
sys.stdin, sys.stdout), and changes the Cmd methods
throughout to use self.stdout.write() and 
self.stdin.foo for output and input. This allows much
greater flexibility for using cmd - for instance, 
hooking it into a telnet server. And if the response
is YAGNI, well, actually, IAGNI, because it's in use
today (and for the last year). :)

If this is acceptable, I'll provide a documentation
patch as well.
msg40061 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-06-02 12:45
Logged In: YES 
user_id=21627

There's no uploaded file!  You have to check the
checkbox labeled "Check to Upload & Attach File"
when you upload a file.

Please try again.

(This is a SourceForge annoyance that we can do
nothing about. :-( )
msg40062 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2002-06-06 01:20
Logged In: YES 
user_id=29957

damn. here's patch
msg40063 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-06-06 01:37
Logged In: YES 
user_id=6380

+1.  But before you check it in, watch out -- looks like the
patch is older than current CVS, and it is missing a number
of improvements that Raymond Hettinger checked in.

Hm, what's this?

self.stdout.write('*** Unknown syntax: %s
(%s)\n'%(str(line),repr(line)))

Why write the contents of the line twice?

It also looks like the patch is a reverse diff.
msg40064 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2002-06-06 07:08
Logged In: YES 
user_id=29957

reverse diff - oops. The str(line) repr(line) bit is because
when hooking
it into telnet, sometimes you get wierd control characters
at the start. The
str/repr is so that you can actually read the line. I'll
kill the str() bit.
msg40065 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-06-06 13:03
Logged In: YES 
user_id=6380

OK, go ahead and check it in then. (Modulo the warnings
below.)
msg40066 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2003-02-06 01:52
Logged In: YES 
user_id=29957

Checking in Lib/cmd.py;
/cvsroot/python/python/dist/src/Lib/cmd.py,v  <--  cmd.py
new revision: 1.35; previous revision: 1.34
done
Checking in Doc/lib/libcmd.tex;
/cvsroot/python/python/dist/src/Doc/lib/libcmd.tex,v  <-- 
libcmd.tex
new revision: 1.13; previous revision: 1.12
History
Date User Action Args
2022-04-10 16:05:20adminsetgithub: 36630
2002-05-21 05:45:14anthonybaxtercreate