summaryrefslogtreecommitdiff
path: root/cmd2.py
Commit message (Collapse)AuthorAgeFilesLines
* feedback_to_output now defaults to FalseTodd Leonhardt2017-08-201-1/+1
| | | | This is so that non-essential info which isn't directly associated with command output, such as time elapsed while executing a command, won't redirect when command output is redirected using >, >>, or |.
* Ensure editor and the file to edit can have spaces in themJared Crapo2017-08-191-1/+1
|
* .pfeedback() now honors feedback_to_output settingJared Crapo2017-08-191-1/+1
| | | | If feedback_to_output is false, .pfeedback() now sends messages to stderr instead of stdout.
* Bump versions to 0.7.7aTodd Leonhardt2017-08-151-1/+1
| | | | This is to help distinguish latest code in GitHub from a version installed via pip from PyPI
* Updated commentKevin Van Brunt2017-08-151-2/+4
|
* Added workaround for bug in Python 2 on Linux when pygtk is installedTodd Leonhardt2017-08-151-0/+8
| | | | This bug is exposed by cmd2's dependency on pyperclip and pyperclip's optional dependency on pygtk.
* The default buffer size is fine for 99% of pipe operationsTodd Leonhardt2017-08-101-7/+2
| | | | | | Removed the complexity of a member variable which would be unnecessary for the vast majority of applications. If users have an application with atypical requirements, they are free to override the default.
* Improved commentKevin Van Brunt2017-08-101-1/+3
|
* Merge branch 'master' into buffer_sizeTodd Leonhardt2017-08-101-1/+1
|\
| * Fix for occasional extra output at startup when using Python 2.7 on LinuxTodd Leonhardt2017-08-101-1/+1
| |
* | Added pipe buffer size that can be tweaked if stdin/stdout need to be larger ↵Kevin Van Brunt2017-08-101-5/+14
|/ | | | | | when piping to shell commands. Fixed error caused by BrokenPipeError not existing in Python 2.
* Made a few code ruggedizationsTodd Leonhardt2017-08-091-15/+18
| | | | | | - poutput() can now take any argument convertible to a str via '{}'.format() instead of only str - postparsing_postcmd() automatically runs a 'stty sane' on POSIX OSes to handle those cases of your terminal getting in a messed up state if you do something like pipe to a terminal command like "less" and then improperly quit out of it with a <Ctrl>-C instead of properly using "q" - In _restore_output(), immeditelly restore stdout state in a finally block after closing the temporary one used for redirection/piping
* Minor tweak to wording of a comment for clarificationTodd Leonhardt2017-08-081-1/+1
|
* Slight rewording to a comment to make it more accurateTodd Leonhardt2017-08-081-1/+1
|
* Replaced direct calls to self.stdout.write() with calls to self.poutput().Todd Leonhardt2017-08-081-23/+40
| | | | | | Modified implementation of poutput() to accept an optional "end" argument which can change the ending to something other than a newline or simply suppress adding a newline. Also added a try/except to catch BrokenPipeError exceptions which can occupoutputr if the subprocess output is being piped to closes before the command piping output to it is finished. Updated install docs to note that when using Python 2.7, the subprocess32 module should also be installed.
* Changed how the pipe file descriptors get opened on Python 3 vs 2Todd Leonhardt2017-08-071-2/+9
| | | | | | | | Open them in text mode in Python 3 so self.stdout.write() expects normal Python 3 (unicode) strings. Open them in binary mode in Python 2 so self.stdout.write() expects normal Python 2 (byte) strings. Also fixed a unit test mocking issue on Python 2 to account for the fact that Python 2.7 requires the subprocess32 module instead of subprocess.
* First attempt at improving how command output gets piped to a shell commandTodd Leonhardt2017-08-071-40/+55
| | | | | | | | | | Now a real pipe is created to a subprocess. This has many advantages and should "just work" like intended with all commands. One downside is to work properly on Python 2.7, it requires the subprocess32 module which is the subprocess module from Python 3.2 backported to Python 2.7. Another downside, is that unit testing the feature is now more difficult. This still needs to be tested for compatibility across all OSes and supported versions of Python. The user needs to be careful if designing multi-threaded cmd2 applications that do command processing in other threads and those threads can make calls to self.stdout.write to put in a try/except to catch Broken Pipe errors which can occur for long running commands if the user closes the shell subprocess before the command is finished.
* Updated CHANGES and bumped version in preparation for 0.7.6 releaseTodd Leonhardt2017-08-021-1/+1
|
* Added strip_ansi() function and visible_prompt properyTodd Leonhardt2017-08-021-6/+30
| | | | | | Transcript testing now strips ANSI escape codes from the current line and current prompt before comparing the start of the current line with the current prompt to see if it is a command. This makes it easier to use transcript testing with applications that colorize the prompt.
* Corrected help text for shortcuts since they don't have to be single keyKevin Van Brunt2017-07-191-1/+1
|
* Added support for case-insensitive tab-completion of cmd2 command namesTodd Leonhardt2017-07-131-1/+5
|
* Fixed a couple case sensitivity bugs and added an exampleTodd Leonhardt2017-07-121-2/+6
| | | | | | | | Bugs fixed: - Case-sensitive parsing was completely broken, this has been fixed - <Ctrl>+D to quit wasn't working when case-sensitive parsing was enabled, this is fixed Added a "case_sensitive.py" example in the examples directory for quickly testing case-sensitive command parsing behavior.
* Fixed a few typosTodd Leonhardt2017-07-111-3/+3
|
* Fixed a comment and updated CHANGESTodd Leonhardt2017-07-101-1/+1
|
* Minor attempt at ruggedization of clipboard stuff in some weird cases on ↵Todd Leonhardt2017-07-101-1/+2
| | | | Python 2
* Attempt at fixing some extraneous output on Linux when using Python3 and xclipTodd Leonhardt2017-07-101-1/+6
|
* Fix a typo: paramters -> parametersFelix Yan2017-07-101-1/+1
|
* Bump version to 0.7.6a (from 0.7.5)Todd Leonhardt2017-07-081-1/+1
|
* Bump version to 0.7.5 (from 0.7.5a)0.7.5Todd Leonhardt2017-07-081-1/+1
|
* Added a few more unit testsTodd Leonhardt2017-07-081-3/+6
|
* Remove ugly file hack code which is no longer necessary as a Python 2/3 ↵Todd Leonhardt2017-07-081-11/+12
| | | | compatibility shim
* Load command uses utf-8 encoding for opening files in Python 3 instead of ↵Todd Leonhardt2017-07-081-3/+9
| | | | | | OS-default This fixes a unit test bug where on Windows it was trying to load a utf-8 file as some other encoding starting with "cp".
* Added an eos (end of script) hidden command and load now populates the cmdqueueTodd Leonhardt2017-07-081-40/+36
| | | | | | The load command no longer spawns a nested main loop using _cmdloop(). It now simply adds commands to the cmdqueue. And after adding all commands in the script file, it adds the eos command. The eos command simply pops the most recent script directory from the list of script directories.
* Removed some extra newlines from error messages in do_load() and ↵Todd Leonhardt2017-07-051-5/+5
| | | | do__relative_load()
* Fixed a few bugs and examplesTodd Leonhardt2017-07-031-18/+14
| | | | | | | | | | | | | | Bug fixes: - case_insensitive is no longer a runtime-settable parameter, but it was still listed as such - Fixed a recursive loop bug when abbreviated commands are enabled and it could get stuck in the editor forever - Added additional command abbreviations to the "exclude from history" list - Fixed argparse_example.py and pirate.py examples Other changes: - Organized all attributes used to configure the ParserManager into a single location - Set the default value of "abbrev" to False (which controls whether or not abbreviated commands are allowed) - With good tab-completion of command names, using abbreviated commands isn't a particularly useful feature - And it can create problems
* Bump version to 0.7.5aTodd Leonhardt2017-07-031-33/+4
|
* Removed pause commandTodd Leonhardt2017-07-031-10/+33
| | | | | | It was pretty useless, it just printed a message and sat there and waited for the user to hit enter. It didn't feel like it belonged in a top-level framework. If a particular application wants this functionality, it is a 2 line change to add it back.
* Fixed bugs, removed dead code, and added unit testsTodd Leonhardt2017-07-021-18/+4
| | | | | | | | | | | Fixed a bug where CmdResult named tuple Truthiness wasn't working in Python 2 Removed unused cmd2.History.search() method. Added unit tests for: - History class - cast() function - CmdResult namedtuple
* Fixed bug where I was accidentally using a feature that is only available in ↵Todd Leonhardt2017-07-021-5/+3
| | | | Python 3.6
* Added a bunch of unit testsTodd Leonhardt2017-07-021-24/+24
| | | | Also improved error handling in some exceptional cases.
* Removed unnecessary try/except in do_shellTodd Leonhardt2017-07-021-8/+3
| | | | Since in the subprocess.Popen() call, shell=True and stderr=sys.stderr, errors get printed on stderr. There is no need to catch an exception.
* shell command now uses cmd.Cmd.stdout for outputTodd Leonhardt2017-07-021-9/+3
| | | | | | | | | The main advantages of this are that shell command output can now be - piped to another shell command - redirected to a file In the future, I may take it a step further where the output is piped, but using a pipe versus a real terminal changes the behavior of many shell commands, for example by getting rid of ANSI color and various other pretty formatting.
* First pass at refactoring shell commandTodd Leonhardt2017-07-021-1/+10
|
* Stopped skipping a unit test on Windows which should pass nowTodd Leonhardt2017-07-011-2/+1
|
* Fixed unicode bug on Windows in pyscript commandTodd Leonhardt2017-07-011-3/+4
| | | | | | Without using the repr representation of the path, "C:\Users" treats \U as a Unicode Escape. To fix this, pyscript passes the repr representation of the path to do_py.
* Added some unit tests related to help and the help menuTodd Leonhardt2017-07-011-1/+3
| | | | | | | Also: - When running cmd2.py as main, enable use of IPython if present to aid with debugging and troubleshooting - Deleted a unit test which wasn't reliable
* Fix issue where pyperclip was printing line on startup when clipboard is emptyTodd Leonhardt2017-06-301-1/+1
| | | | Also skip unit test which passes when I run it on my systems, but fails on TravisCI and AppVeyor
* Refactored clipboard code to make it a tiny bit simplerTodd Leonhardt2017-06-301-21/+18
| | | | Also added a few unit tests related to running an empty statement and dealing with precmd hook success and failure.
* Fixed a sys.platform checkTodd Leonhardt2017-06-301-1/+1
| | | | So it turns out that on Linux, it sys.platform is "linux2" in Python 2 and "linux" in Python 3, so if doing a comparsion, need to do a .startswith() instead of a ==
* Added code to set can_clip to False on Linux if can't copy/paste clipboardTodd Leonhardt2017-06-301-1/+6
| | | | | | | If Pyperclip could not find a copy/paste mechanism for your system, then cmd2.can_clip gets set to False. If cmd2.can_clip is False, then the "send_to_paste_buffer" test gets skipped.