mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 17:00:58 +01:00
_hist_show deal with multiple slices
This commit is contained in:
parent
d39ac8836a
commit
3cb22ad9c4
1 changed files with 14 additions and 13 deletions
|
@ -375,7 +375,7 @@ def _hist_create_parser():
|
||||||
help='reverses the direction')
|
help='reverses the direction')
|
||||||
show.add_argument('session', nargs='?', choices=HIST_SESSIONS, default='session',
|
show.add_argument('session', nargs='?', choices=HIST_SESSIONS, default='session',
|
||||||
help='Choose a history session, defaults to current 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')
|
help='display history entries or range of entries')
|
||||||
# 'id' subcommand
|
# 'id' subcommand
|
||||||
subp.add_parser('id', help='displays the current session id')
|
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.")
|
print("Invalid end time, must be float or datetime.")
|
||||||
idx = None
|
idx = None
|
||||||
if ns:
|
if ns:
|
||||||
idx = ensure_slice(ns.n)
|
_commands = []
|
||||||
if idx is False:
|
for s in ns.slices:
|
||||||
print("{} is not a valid input.".format(ns.n),
|
s = ensure_slice(s)
|
||||||
file=sys.stderr)
|
if s:
|
||||||
return
|
|
||||||
elif isinstance(idx, int):
|
|
||||||
try:
|
try:
|
||||||
commands = [commands[idx]]
|
_commands.extend(commands[s])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
err = "Index likely not in range. Only {} commands."
|
err = "Index likely not in range. Only {} commands."
|
||||||
print(err.format(len(commands)))
|
print(err.format(len(commands)), file=sys.stderr)
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
if _commands:
|
||||||
|
commands = _commands
|
||||||
else:
|
else:
|
||||||
idx = slice(start_index, end_index)
|
idx = slice(start_index, end_index)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue