Commit Graph

43 Commits

Author SHA1 Message Date
Raymond Hettinger 66dd94199c Issue 15337: help() shown as undocumented 2012-07-16 00:11:05 -07:00
Jesus Cea a94b578431 Close #13500: Hitting EOF gets cmd.py into a infinite EOF on return loop 2011-12-06 20:46:04 +01:00
R. David Murray 58f15b66ff Merged revisions 83380 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83380 | r.david.murray | 2010-07-31 23:31:09 -0400 (Sat, 31 Jul 2010) | 17 lines

  #8620: Cmd no longer truncates last character if stdin ends without newline

  Cmd used to blindly chop off the last character of every input line.  If
  the input reached EOF and there was no final new line, it would truncate
  the last character of the last command.  This fix instead strips trailing
  \r\n from the input lines.  While this is a small behavior change, it
  should not break any working code, since feeding a '\r\n' terminated
  file to Cmd would previously leave the \r's on the lines, resulting
  in failed command execution.

  I wrote the unit test in preparation for a PyOhio TeachMe session
  run by Catherine Devlin, and we can thank Catherine and the PyOhio
  session attendees for the fix.  I've added Catherine to the Acks file
  for organizing and leading the TeachMe session, out of which we will
  hopefully get some new contributors.
........
2010-08-01 04:04:03 +00:00
Georg Brandl 8904053003 #5991: let completion for the "help" command include help topics.
This also simplifies the Cmd.get_names() method implementation; it was written
at a time where dir() didn't consider base class attributes.
2010-01-06 18:02:16 +00:00
Tim Peters 4e0e1b6a54 Whitespace normalization. 2004-07-07 20:54:48 +00:00
Michael W. Hudson d7cc1bd809 Fix
[ 924301 ] A leak case with cmd.py & readline & exception

by ensuring that the readline completion function is always reset
even in the case of an exception being raised.  As a bonus, this
makes the documentation for pre & postloop accurate again.
2004-07-01 14:52:10 +00:00
Andrew M. Kuchling 7cebbf39a9 Add docstring 2003-10-22 14:38:54 +00:00
Tim Peters f2715e0764 Whitespace normalization. 2003-02-19 02:35:07 +00:00
Anthony Baxter 983b008824 Updated version of [ 558544 ] cmd.py: add instance-specific stdin/out
This 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.

Patch for library module and for documentation.
2003-02-06 01:45:11 +00:00
Michael W. Hudson 35a92ce9da Fix bug
[ 676342 ] after using pdb readline does not work correctly

using Michael Stone's patch so the completer functionality of
cmd is only setup between preloop and postloop.
2003-02-03 11:04:27 +00:00
Guido van Rossum 87fec22476 Duh. cmdqueue should be an instance variable, not a class variable.
This was introduced in 1998 in rev. 1.13, where I imported extensive
patches that, I am sad to say, I didn't review as carefully as I
should have.
2003-01-13 21:18:54 +00:00
Guido van Rossum c706c28d75 Add a better columnizer to print_topics(). 2002-12-02 13:08:53 +00:00
Raymond Hettinger 46ac8eb3c8 Code modernization. Replace v=s[i]; del s[i] with single lookup v=s.pop(i) 2002-06-30 03:39:14 +00:00
Raymond Hettinger 54f0222547 SF 563203. Replaced 'has_key()' with 'in'. 2002-06-01 14:18:47 +00:00
Raymond Hettinger aef22fb9cd Patch 560023 adding docstrings. 2.2 Candidate (after verifying modules were not updated after 2.2). 2002-05-29 16:18:42 +00:00
Skip Montanaro 1ce0073a4e tighten up except - in this context, AttributeError is the only exception
that can be raised - do_help won't be called if arg is not a string
2002-03-24 16:34:21 +00:00
Neil Schemenauer d03c342b99 Flush stdout before reading next command. Closes SF bug 526357. 2002-03-23 20:43:59 +00:00
Tim Peters ab9ba27dc0 Whitespace normalization. 2001-08-09 21:40:30 +00:00
Martin v. Löwis 66b6e192b9 Patch #416224: add readline completion to cmd.Cmd. 2001-07-28 14:44:03 +00:00
Fred Drake 79e75e1916 Use string.ascii_letters instead of string.letters (SF bug #226706). 2001-07-20 19:05:50 +00:00
Guido van Rossum bfb9184ba8 This is SF patch #405952, by Anthony Baxter:
cmd.py uses raw_input(); eats SIGCLD:

  I discovered a rather nasty side effect of the standard cmd.py
  library today. If it's sitting inside raw_input(), any SIGCLDs that
  get sent to your application get silently eaten and ignored. I'm
  assuming that this is something that readline is thoughtfully doing
  for me.

  This patch adds an instance attr that allows the user to select to
  not use raw_input(), but instead use sys.stdin.readline()

[Changed slightly to catch EOFError only for raw_input().]
2001-03-22 21:59:20 +00:00
Eric S. Raymond 20e4423ade String method conversion. 2001-02-09 04:52:11 +00:00
Jeremy Hylton d30e587e00 unnecessary semicolon 2001-01-26 17:15:18 +00:00
Skip Montanaro e99d5ea25b added __all__ lists to a number of Python modules
added test script and expected output file as well
this closes patch 103297.
__all__ attributes will be added to other modules without first submitting
a patch, just adding the necessary line to the test script to verify
more-or-less correct implementation.
2001-01-20 19:54:20 +00:00
Fred Drake 8152d32375 Update the code to better reflect recommended style:
Use != instead of <> since <> is documented as "obsolescent".
Use "is" and "is not" when comparing with None or type objects.
2000-12-12 23:20:45 +00:00
Eric S. Raymond 5f1b27084a Bug fix: ? and ! were not full aliases for `help' and `shell' as implied in
the documentation; the cases `? foo' and `! foo' failed.
2000-07-11 13:03:55 +00:00
Guido van Rossum 4acc25bd39 Mass patch by Ka-Ping Yee:
1. Comments at the beginning of the module, before
       functions, and before classes have been turned
       into docstrings.

    2. Tabs are normalized to four spaces.

Also, removed the "remove" function from dircmp.py, which reimplements
list.remove() (it must have been very old).
2000-02-02 15:10:15 +00:00
Guido van Rossum db6d12c498 No need to import sys or linecache. (Andrew Dalke & kjpylint) 1999-05-03 18:08:16 +00:00
Guido van Rossum d5138caba5 Patch by Michael Scharf. He writes:
The module cmd requires for each do_xxx command a help_xxx
    function. I think this is a little old fashioned.

    Here is a patch: use the docstring as help if no help_xxx
    function can be found.

[I'm tempted to rip out all the help_* functions from pdb, but I'll
resist it.  Any takers?  --Guido]
1999-03-12 22:15:43 +00:00
Guido van Rossum 5fca6fd2d9 Richard Wolff's changes:
cmd.py  has incorporated the changes we discussed a couple of weeks ago
	(a command queue, returning line from precmd, and stop from postcmd)
	and some changes to help that were occasioned because I wanted to
	inherit from pdb which inherits from cmd.py and the help routine
	didn't look for commands or the associated help deeply enough.
1998-09-11 22:33:08 +00:00
Guido van Rossum b9f48608f6 Changes by Richard Wolff:
1) I added a command queue which is helpful to me (at least so far) and
   would also allow syntax like 's;s' (step; step) in conjunction with precmd
2) doc_leader allows the derived class to print a message before the help
   output.  Defaults to current practise of a blank line
3) nohelp allows one to override the 'No help on' message.  I need
    'Undefined command: "%s".  Try "help".'
4) Pass line to self.precmd to allow one to do some parsing: change first
   word to lower case, strip out a leading number, whatever.
5) Pass the result of onecmd and the input line to postcmd.  This allows
   one to ponder the stop result before it is effective.
6) emptyline() requires a   if self.lastcmd:  conditional because if the
   first command is null (<cr>), you get an infinite recursion with the
   code as it stands.
1998-08-27 19:02:51 +00:00
Guido van Rossum c612681b20 Fix another bug in ESR's changes. In order to work properly,
onecmd(line) must return the value returned by emptyline() or
default(line).
1998-07-20 21:22:08 +00:00
Guido van Rossum 030eb11823 Gotta have an __init__() method -- pdb.py calls it! 1998-07-01 22:53:04 +00:00
Guido van Rossum 80884075f0 Improved by Eric Raymond. 1998-06-29 17:58:55 +00:00
Guido van Rossum 7ef2a1de9b Shouldn't use newdir.dir(), which no longer exists! 1998-05-22 14:11:57 +00:00
Guido van Rossum b6775db241 Merge alpha100 branch back to main trunk 1994-08-01 11:34:53 +00:00
Guido van Rossum 7bc817d5ba * Mass change: get rid of all init() methods, in favor of __init__()
constructors.  There is no backward compatibility.  Not everything has
  been tested.
* aiff.{py,doc}: deleted in favor of aifc.py (which contains its docs as
  comments)
1993-12-17 15:25:27 +00:00
Guido van Rossum 5ef74b8f8e pdb.py, bdb.py, cmd.py: use __init__() instead of init() 1993-06-23 11:55:24 +00:00
Guido van Rossum 9b3bc71598 * aifc.py: don't die on invalid MARK chunk
* calendar.py: remove stuff now built in time; some cleanup and
  generalization in the calendar printing
* cmd.py: use __init__.
* tzparse.py: This module is no longer necessary -- use builtin time instead!
1993-06-20 21:02:22 +00:00
Guido van Rossum c629d34c4f * change default line numbers for 'list' in pdb.py
* changed eval() into getattr() in cmd.py
* added dirname(), basename() and (dummy) normath() to macpath.py
* renamed nntp.py to nntplib.py
* Made string.index() compatible with strop.index()
* Make string.atoi('') raise string.atoi_error rather than ValueError
* Added dirname() and normpath() to posixpath.
1992-11-05 10:43:02 +00:00
Guido van Rossum 732282fa11 Module getattr doesn't exist any more, it's now called newdir. 1992-08-19 16:49:37 +00:00
Guido van Rossum d7d8cd44c1 Don't print repeated commands. 1992-01-27 16:59:04 +00:00
Guido van Rossum b53e67837b Initial revision 1992-01-24 01:12:17 +00:00