Crates.io | pype |
lib.rs | pype |
version | 0.2.1 |
source | src |
created_at | 2023-02-23 09:52:03.59708 |
updated_at | 2023-03-07 20:31:40.015251 |
description | Python oneliner helper |
homepage | |
repository | |
max_upload_size | |
id | 792505 |
size | 56,258 |
Python one-liner helper written in Rust.
cargo install pype
stdin is opened as f
.
Prepare sample1
file.
cat > sample1
1
2
3
Execute specified python code.
$ cat sample1 | pype -e 'print(f.read())' | python
1
2
3
$ cat sample1 | pype -e 'print(f.read().splitlines())' | python
['1', '2', '3']
Execute specified python code per line. You can access via line
variable to each line.
$ cat sample1 | pype -ne 'print("- " + line)' | python
- 1
- 2
- 3
$ cat sample1 | pype -ne 'print("- " + line + "$")' | python
- 1
$- 2
$- 3
Available when -n
is specified. Removes trailing newlines from the input and adds newlines to print
.
$ cat sample1 | pype -nle 'print("- " + line)' | python
- 1
- 2
- 3
$ cat sample1 | pype -nle 'print("- " + line + "$")' | python
- 1$
- 2$
- 3$
Import specified module before executing python code.
cat sample1 | pype -m datetime -nle 'print(f"- {line}:", (datetime.date.today() + datetime.timedelta(days=int(line))))' | python
- 1: 2023-03-09
- 2: 2023-03-10
- 3: 2023-03-11
Apache License 2.0