Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
anki-code authored Apr 3, 2024
1 parent 9963492 commit 7d19eef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions xontrib/pipeliner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ def _pl(args, stdin, stdout):
if len(args) == 0:
print('Error: Python code not found', file=sys.stderr)
err = True

presets = {**_default_presets, **__xonsh__.env.get('XONTRIB_PIPELINER_PRESETS', {})}
if err:
print('Usage: <command> | <command> | ... | pl "<Python code>"', file=sys.stderr)
print('Example: echo "123" | pl "line[::-1]"', file=sys.stderr)
print('Usage: <command> | <command> | ... | pl "<Python code>"\n'
+ 'Example: echo "123" | pl "line[::-1]"\n'
+ 'Presets:\n' + '\n'.join(f" {p}: {repr(v) if type(v) is str else 'func'}" for p,v in presets.items())
, file=sys.stderr)
return

presets = {**_default_presets, **__xonsh__.env.get('XONTRIB_PIPELINER_PRESETS', {})}
if args[0] in presets:
preset = presets[args[0]]
args = [preset(args[1:])] if callable(preset) else [preset]
Expand Down

0 comments on commit 7d19eef

Please sign in to comment.