Skip to content

Commit feae68c

Browse files
authored
Update README.md
1 parent 559df01 commit feae68c

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,34 @@ Done command with /cdrom
125125
```
126126
Note! If you do the operations with files (i.e. `pl "execx(f'mv {line} prefix-{line}')"`) you could catch `TypeError: an integer is required` error that relates to wrong access rights to files. Fix it with `chmod` and `chown` before pipelining.
127127

128+
## Presets
129+
130+
There are default presets:
131+
```xsh
132+
echo " 1" | pl strip
133+
# 1
134+
135+
echo "1,2,3" | pl split ,
136+
['1', '2', '3']
137+
138+
echo "a,b,c" | pl split , | pl list 0
139+
# a
140+
```
141+
142+
You can set your own presets:
143+
```xsh
144+
$XONTRIB_PIPELINER_PRESETS = {
145+
"upper": "line.upper()",
146+
"repeat": lambda args: f"line*int({repr(args[0])})"
147+
}
148+
149+
echo 'hello' | pl upper
150+
# HELLO
151+
152+
echo 'hey ' | pl repeat 3
153+
# hey hey hey
154+
```
155+
128156
## Wrap pipeliner to get your own magic
129157
```python
130158
aliases['my_lovely_pl'] = lambda a,i,o: aliases['pl'](["'My lovely ' + "+a[0]], i, o)

0 commit comments

Comments
 (0)