From c7a61bbf5d22670a39d8466007ec17be92dbffd7 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Tue, 14 Feb 2017 15:27:40 -0500 Subject: [PATCH] cleanup --- xonsh/xoreutils/echo.py | 19 ++++++++++++++++++- xonsh/xoreutils/pwd.py | 17 ++++++++++------- xonsh/xoreutils/tee.py | 4 ++++ xonsh/xoreutils/tty.py | 10 +++++----- xonsh/xoreutils/yes.py | 12 ++++++------ xontrib/coreutils.py | 2 +- 6 files changed, 44 insertions(+), 20 deletions(-) diff --git a/xonsh/xoreutils/echo.py b/xonsh/xoreutils/echo.py index 9034a8271..c84ded2f6 100644 --- a/xonsh/xoreutils/echo.py +++ b/xonsh/xoreutils/echo.py @@ -1,4 +1,4 @@ -"""Impelements a simple echo command for xonsh.""" +"""Implements a simple echo command for xonsh.""" def echo(args, stdin, stdout, stderr): @@ -6,6 +6,9 @@ def echo(args, stdin, stdout, stderr): opts = _echo_parse_args(args) if opts is None: return + if opts['help']: + print(ECHO_HELP, file=stdout) + return 0 ender = opts['end'] args = map(str, args) if opts['escapes']: @@ -24,4 +27,18 @@ def _echo_parse_args(args): if '-n' in args: args.remove('-n') out['end'] = '' + if '-h' in args or '--help' in args: + out['help'] = True return out + + +EHCO_HELP = """Usage: echo [OPTIONS]... [STRING]... +Echo the STRING(s) to standard output. + + -n do not include the trailing newline + -e enable interpretation of backslash escapes + -E disable interpretation of backslash escapes (default) + -h --help display this message and exit + +This version of echo was written in Python for the xonsh project: http://xon.sh +Based on echo from GNU coreutils: http://www.gnu.org/software/coreutils/""" diff --git a/xonsh/xoreutils/pwd.py b/xonsh/xoreutils/pwd.py index 5214cebf6..34288363d 100644 --- a/xonsh/xoreutils/pwd.py +++ b/xonsh/xoreutils/pwd.py @@ -5,7 +5,7 @@ import os def pwd(args, stdin, stdout, stderr): """A pwd implementation""" e = __xonsh_env__['PWD'] - if '--help' in args: + if '-h' in args or '--help' in args: print(PWD_HELP, file=stdout) return 0 if '-P' in args: @@ -14,12 +14,15 @@ def pwd(args, stdin, stdout, stderr): return 0 -PWD_HELP = """This version of pwd was written in Python for the xonsh project: http://xon.sh -Based on pwd from GNU coreutils: http://www.gnu.org/software/coreutils/ - -Usage: pwd [OPTION]... +PWD_HELP = """Usage: pwd [OPTION]... Print the full filename of the current working directory. - -L, --logical use PWD from environment, even if it contains symlinks -P, --physical avoid all symlinks - --help display this help and exit""" + --help display this help and exit + +This version of pwd was written in Python for the xonsh project: http://xon.sh +Based on pwd from GNU coreutils: http://www.gnu.org/software/coreutils/""" + + +# Not Implemented +# -L, --logical use PWD from environment, even if it contains symlinks diff --git a/xonsh/xoreutils/tee.py b/xonsh/xoreutils/tee.py index b6991cf99..874e85efd 100644 --- a/xonsh/xoreutils/tee.py +++ b/xonsh/xoreutils/tee.py @@ -13,6 +13,10 @@ def tee(args, stdin, stdout, stderr): if '--help' in args: print(TEE_HELP, file=stdout) return 0 + if stdin is None: + msg = "tee was not piped stdin, must have input stream to read from." + print(msg, file=stderr) + return 1 errors = False files = [] diff --git a/xonsh/xoreutils/tty.py b/xonsh/xoreutils/tty.py index 6d1fca2d0..c66771421 100644 --- a/xonsh/xoreutils/tty.py +++ b/xonsh/xoreutils/tty.py @@ -34,11 +34,11 @@ def tty(args, stdin, stdout, stderr): return 3 return 0 -TTY_HELP = """This version of tty was written in Python for the xonsh project: http://xon.sh -Based on tty from GNU coreutils: http://www.gnu.org/software/coreutils/ - -Usage: /usr/bin/tty [OPTION]... +TTY_HELP = """Usage: tty [OPTION]... Print the file name of the terminal connected to standard input. -s, --silent, --quiet print nothing, only return an exit status - --help display this help and exit""" + --help display this help and exit + +This version of tty was written in Python for the xonsh project: http://xon.sh +Based on tty from GNU coreutils: http://www.gnu.org/software/coreutils/""" diff --git a/xonsh/xoreutils/yes.py b/xonsh/xoreutils/yes.py index a5786e394..a1aeff092 100644 --- a/xonsh/xoreutils/yes.py +++ b/xonsh/xoreutils/yes.py @@ -15,11 +15,11 @@ def yes(args, stdin, stdout, stderr): return 0 -YES_HELP = """This version of yes was written in Python for the xonsh project: http://xon.sh -Based on yes from GNU coreutils: http://www.gnu.org/software/coreutils/ - -Usage: /usr/bin/yes [STRING]... - or: /usr/bin/yes OPTION +YES_HELP = """Usage: yes [STRING]... + or: yes OPTION Repeatedly output a line with all specified STRING(s), or 'y'. - --help display this help and exit""" + --help display this help and exit + +This version of yes was written in Python for the xonsh project: http://xon.sh +Based on yes from GNU coreutils: http://www.gnu.org/software/coreutils/""" diff --git a/xontrib/coreutils.py b/xontrib/coreutils.py index d4ce854d9..b29820e07 100644 --- a/xontrib/coreutils.py +++ b/xontrib/coreutils.py @@ -1,4 +1,4 @@ -"""Additional core utilites that are implemened in xonsh. The current list +"""Additional core utilites that are implemented in xonsh. The current list includes: * cat