From 3cb22ad9c49de9a102976de510cb591f96ab56bf Mon Sep 17 00:00:00 2001 From: laerus Date: Tue, 19 Jul 2016 00:07:35 +0300 Subject: [PATCH] _hist_show deal with multiple slices --- xonsh/history.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/xonsh/history.py b/xonsh/history.py index b882ce509..617a443d6 100644 --- a/xonsh/history.py +++ b/xonsh/history.py @@ -375,7 +375,7 @@ def _hist_create_parser(): help='reverses the direction') show.add_argument('session', nargs='?', choices=HIST_SESSIONS, default='session', help='Choose a history session, defaults to current session') - show.add_argument('slices', nargs='*', default=[], + show.add_argument('slices', nargs=argparse.REMAINDER, default=[], help='display history entries or range of entries') # 'id' subcommand subp.add_parser('id', help='displays the current session id') @@ -466,18 +466,19 @@ def _hist_show(ns=None, hist=None, start_index=None, end_index=None, print("Invalid end time, must be float or datetime.") idx = None if ns: - idx = ensure_slice(ns.n) - if idx is False: - print("{} is not a valid input.".format(ns.n), - file=sys.stderr) - return - elif isinstance(idx, int): - try: - commands = [commands[idx]] - except IndexError: - err = "Index likely not in range. Only {} commands." - print(err.format(len(commands))) - return + _commands = [] + for s in ns.slices: + s = ensure_slice(s) + if s: + try: + _commands.extend(commands[s]) + except IndexError: + err = "Index likely not in range. Only {} commands." + print(err.format(len(commands)), file=sys.stderr) + return + else: + if _commands: + commands = _commands else: idx = slice(start_index, end_index)