---
name: package
description: Make a Piped package: a folder in ~/pkg/ whose commands others install with `pkg install`, such as a ~/bin script turned into one.
---
1. Run `man pkg` for the rules.
2. Write the command to `~/pkg/NAME/bin/NAME`, a script as any in `~/bin`. More commands go beside it, each named `NAME-…`.
3. A setting, such as a URL or a key, is a variable the script reads, never a value written into it. When the variable is empty, the script says so on stderr, naming `~/pkg/NAME/.env`, and exits 1.
4. Write `~/pkg/NAME/README.md`: its first line says what the package does, as `pkg search` shows it, then how to run it and each setting it needs.
5. You cannot write `.env`: tell the user each line to add to `~/pkg/NAME/.env`, as `SETTING=value`, or `SETTING=` to use their own `~/.env`'s.
6. Run it by name to test it. A `~/bin` script of the same name runs instead: tell the user to rename that one.
7. Publishing is the user's: `pkg publish NAME`, which adds the MIT license and leaves the values in `.env` out.
