Metadata-Version: 2.3
Name: epy-scripts
Version: 0.1.0
Summary: Build one-off Python scripts via stored code at the command line
License: MIT
Author: Ben Skubi
Author-email: skubi@ohsu.edu
Requires-Python: >=3.11
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: click (>=8.4.1,<9.0.0)
Description-Content-Type: text/markdown

Build one-off Python scripts via stored code at the command line.

```
pip install epy
```


Store code defining a function `shell` that runs code via your shell. `-d` makes it run by default. `-k shell` gives the code a unique key "shell". `save` stores this in a default bundle. A bundle is an ordered dict of named code blocks.
```bash
epy set -d -k shell "import subprocess; import functools; shell = functools.partial(subprocess.run, shell=True)" save
```

Execute code using the `shell` command defined above. The code defining the `shell` statement is loaded and run from the default bundle before the `exec` statements.
```bash
epy exec "shell('echo hello world')" exec shell "('echo sincerely, epy')
```

Display code to be run, but don't execute. `-b "*"` also prints all loaded bundles.
```bash
epy exec "shell('echo dry run')" dump -b "*"
```

Create a new bundle, which will NOT be loaded by default.
```bash
epy create --path my_bundle.json my_bundle set -n my_bundle -k greet "print('hello from my bundle')" save
```

Load the bundle and execute the `greet` statement. `greet` is not run by default because it was not generated with `-d`. In the `exec` statement, my_bundle is attached with `-n`. The `greet` statement is the first argument. `epy` searches all explicitly attached bundles
```bash
epy load my_bundle.json exec -a my_bundle -r greet -r "shell('echo hello from the default bundle')"
```


