diff --git a/README.md b/README.md index 65eef93..f95caa9 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,11 @@ and more, written in pure Go, and inspired by [skate](https://github.com/charmbr
-`pda!` stores key-value pairs natively as [newline-delimited JSON](https://en.wikipedia.org/wiki/JSON_streaming#Newline-delimited_JSON) files. Every store is plaintext, portable, and yours. There's no daemon, no cloud service, and no proprietary format. Keys are just lines in a JSON file; stores are just files in a directory. If you can `cat` a file, you can read your data without `pda!` installed. +`pda` stores key-value pairs natively as [newline-delimited JSON](https://en.wikipedia.org/wiki/JSON_streaming#Newline-delimited_JSON) files. [`pda list`](#listing) outputs tabular data by default, but also supports [CSV](https://en.wikipedia.org/wiki/Comma-separated_values), [TSV](), [Markdown]() and [HTML]() tables, [JSON](), and raw NDJSON. Everything is in plaintext to make version control easy, and to avoid tying anybody to using this tool forever. -Git versioning is built in. Enable auto-committing, pushing, and fetching in the [config](#config) to automatically version every change, or just run [`pda sync`](#sync) when you want to. Because the storage format is line-oriented plaintext, diffs are meaningful and merges are clean. +Git versioning can be initiated with [`pda init`](#git), and varying levels of automation can be toggled via the [config](#config): `git.autocommit`, `git.autofetch`, and `git.autopush`. Running Git operations on every change can be slow, but a commit is fast. A happy middle-ground is enabling `git.autocommit` and doing the rest manually via [`pda sync`](#git) when changing devices. -Go's [`text/template`](https://pkg.go.dev/text/template) engine is available on every value at retrieval time, turning simple key-value pairs into dynamic snippets with variables, environment lookups, shell execution, cross-references, and more. +[Templates](#templates) are a primary feature, enabling values to make use of substitutions, environment variables, arbitrary shell execution, cross-references to other keys, and more. @@ -136,59 +136,18 @@ Powershell users will need to manually add the above command to their profile; t Import & Export · Templates · Filtering · - Binary Data + Binary Data · Git · Identity · Config · Environment · Doctor · - Help & Version + Version · + Help -```bash -pda! MIT licensed. (c) 2025 Lewis Wynne - -Usage: - pda [command] - -Key commands: - copy Make a copy of a key - edit Edit a key's value in $EDITOR - get Get the value of a key - identity Show or create the age encryption identity - list List the contents of all stores - meta View or modify metadata for a key - move Move a key - remove Delete one or more keys - run Get the value of a key and execute it - set Set a key to a given value - -Store commands: - export Export store as NDJSON (alias for list --format ndjson) - import Restore key/value pairs from an NDJSON dump - list-stores List all stores - move-store Rename a store - remove-store Delete a store - -Git commands: - git Run any arbitrary command. Use with caution. - init Initialise pda! version control - sync Manually sync your stores with Git - -Environment commands: - config View and modify configuration - doctor Check environment health - -Additional Commands: - completion Generate the autocompletion script for the specified shell - help Help about any command - version Display pda! version -``` - - - Most commands have aliases and flags. Run `pda help [command]` to see them. ### Key commands @@ -196,13 +155,13 @@ Most commands have aliases and flags. Run `pda help [command]` to see them.
↑ ·
- pda set,
- pda get,
- pda run,
- pda list,
- pda edit,
- pda move,
- pda remove
+ Setting,
+ Getting,
+ Running,
+ Listing,
+ Editing,
+ Moving and Copying,
+ Removing
+
+ ↑ ·
+ Templates ·
+ pda get
+
+
+
+ ↑ ·
+ pda get --run ·
+ pda run
+
+
+
+ ↑ ·
+ pda list ·
+ Filtering
+
+
-
- See also:
- pda help list
-
-
↑ ·
- pda edit,
- pda set,
- pda meta
+ pda edit
-
- See also:
- pda help edit
-
-
↑ ·
- pda move,
- pda copy
+ pda move,
+ pda copy
-
- See also:
- pda help move,
- pda help copy
-
-
↑ ·
- pda remove,
- --key
+ pda help remove
-
- See also:
- pda help remove
-
-
@@ -700,20 +594,13 @@ FAIL cannot meta 'api-url': key is read-only pda meta api-url --ttl 1h --force ``` -
-
- See also:
- pda help meta
-
-
↑ ·
- pda set,
- pda meta
+ pda help set,
+ pda help meta
-
- See also:
- pda help set,
- pda help meta
-
-
↑ ·
- pda set,
- pda meta,
- pda identity
+ pda help set,
+ pda help meta,
+ pda help identity
-
- See also:
- pda help set,
- pda help meta,
- pda help identity
-
-
↑ ·
- pda set,
- pda meta,
- pda edit
+ pda help set,
+ pda help meta
-
- See also:
- pda help set,
- pda help meta,
- pda help edit
-
-
↑ ·
- pda set,
- pda meta,
- pda list
+ pda help set,
+ pda help meta
-
- See also:
- pda help set,
- pda help meta
-
-
@@ -1027,22 +878,13 @@ pda remove-store birthdays pda remove-store birthdays -y ``` -
-
- See also:
- pda help list-stores,
- pda help move-store,
- pda help remove-store
-
-
↑ ·
- pda export,
- pda import
+ pda help export,
+ pda help import
-
- See also:
- pda help export,
- pda help import
-
-
@@ -1132,8 +966,7 @@ These same functions are also available in `git.default_commit_message` template
↑ ·
- Templates,
- pda get
+ Templates
↑ ·
- pda get
+ pda help get
-
- See also:
- pda help get,
- pda help set
-
-
@@ -1546,14 +1371,6 @@ pda rm cat --key "{mouse,[cd]og}**" # ... ``` -
-
- See also:
- pda help list,
- pda help remove
-
-
@@ -1601,14 +1418,6 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADklEQVQI12... [`pda edit`](#editing) presents binary values as base64 for editing and decodes them back on save. -
-
- See also:
- pda help set,
- pda help get
-
-
@@ -1627,8 +1436,7 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADklEQVQI12...
↑ ·
- Git,
- pda sync
+ pda help init
-
- See also:
- pda help init
-
-
↑ ·
- Git
+ pda help sync
-
- See also:
- pda help sync
-
-
↑ ·
- Git,
- Config
+ pda help config
↑ ·
- pda identity
+ pda help identity
↑ ·
- pda identity
+ pda help identity
↑ ·
- pda identity,
- Encryption
+ pda help identity
-
- See also:
- pda help identity
-
-
@@ -1819,7 +1604,7 @@ Config is stored at `~/.config/pda/config.toml` (Linux/macOS) or `%LOCALAPPDATA%
↑ ·
- pda config
+ pda help config
-
- See also:
- pda help config
-
-
↑ ·
- Config
+ Config,
+ pda help config
-
- See also:
- pda help doctor
-
-
- ↑
+ ↑ ·
+ pda help version
+ + ↑ + +
+ +set ·
+ get ·
+ run ·
+ list ·
+ edit ·
+ move ·
+ copy ·
+ remove ·
+ meta ·
+ identity ·
+ export ·
+ import ·
+ list-stores ·
+ move-store ·
+ remove-store ·
+ init ·
+ sync ·
+ git ·
+ config ·
+ doctor ·
+ version
++ + ↑ · + See also: + Setting + +
+ +```text +Set a key to a given value or stdin. Optionally specify a store. + +Pass --encrypt to encrypt the value at rest using age. An identity file +is generated automatically on first use. + +PDA supports parsing Go templates. Actions are delimited with {{ }}. + +For example: + 'Hello, {{ .NAME }}' can be substituted with NAME="John Doe". + 'Hello, {{ env "USER" }}' will fetch the USER env variable. + 'Hello, {{ default "World" .NAME }}' will default to World if NAME is blank. + 'Hello, {{ require .NAME }}' will error if NAME is blank. + '{{ enum .NAME "Alice" "Bob" }}' allows only NAME=Alice or NAME=Bob. + +Usage: + pda set KEY[@STORE] [VALUE] [flags] + +Aliases: + set, s + +Flags: + -e, --encrypt encrypt the value at rest using age + -f, --file string read value from a file + --force bypass read-only protection + -h, --help help for set + -i, --interactive prompt before overwriting an existing key + --pin pin the key (sorts to top in list) + --readonly mark the key as read-only + --safe do not overwrite if the key already exists + -t, --ttl duration expire the key after the provided duration (e.g. 24h, 30m) +``` + +#### `pda get` + ++ + ↑ · + See also: + Getting, + Templates + +
+ +```text +Get the value of a key. Optionally specify a store. + +{{ .TEMPLATES }} can be filled by passing TEMPLATE=VALUE as an +additional argument after the initial KEY being fetched. + +For example: + pda set greeting 'Hello, {{ .NAME }}!' + pda get greeting NAME=World + +Usage: + pda get KEY[@STORE] [flags] + +Aliases: + get, g + +Flags: + -b, --base64 view binary data as base64 + --exists exit 0 if the key exists, exit 1 if not (no output) + -h, --help help for get + --no-template directly output template syntax + -c, --run execute the result as a shell command +``` + +#### `pda run` + ++ + ↑ · + See also: + Running, + Templates + +
+ +```text +Get the value of a key and execute it as a shell command. Optionally specify a store. + +{{ .TEMPLATES }} can be filled by passing TEMPLATE=VALUE as an +additional argument after the initial KEY being fetched. + +For example: + pda set greeting 'Hello, {{ .NAME }}!' + pda run greeting NAME=World + +Usage: + pda run KEY[@STORE] [flags] + +Flags: + -b, --base64 view binary data as base64 + -h, --help help for run + --no-template directly output template syntax +``` + +#### `pda list` + ++ + ↑ · + See also: + Listing, + Filtering + +
+ +```text +List the contents of all stores. + +By default, list shows entries from every store. Pass a store name as a +positional argument to narrow to a single store, or use --store/-s with a +glob pattern to filter by store name. + +Use --key/-k and --value/-v to filter by key or value glob, and --store/-s +to filter by store name. All filters are repeatable and OR'd within the +same flag. + +Usage: + pda list [STORE] [flags] + +Aliases: + list, ls + +Flags: + -a, --all list across all stores + -b, --base64 view binary data as base64 + -c, --count print only the count of matching entries + -o, --format format output format (table|tsv|csv|markdown|html|ndjson|json) + -f, --full show full values without truncation + -h, --help help for list + -k, --key strings filter keys with glob pattern (repeatable) + --no-header suppress the header row + --no-keys suppress the key column + --no-meta suppress the meta column + --no-size suppress the size column + --no-store suppress the store column + --no-ttl suppress the TTL column + --no-values suppress the value column + -s, --store strings filter stores with glob pattern (repeatable) + -v, --value strings filter values with glob pattern (repeatable) +``` + +#### `pda edit` + ++ + ↑ · + See also: + Editing + +
+ +```text +Open a key's value in $EDITOR. If the key doesn't exist, opens an +empty file — saving non-empty content creates the key. + +Binary values are presented as base64 for editing and decoded back on save. + +Metadata flags (--ttl, --encrypt, --decrypt) can be passed alongside the edit +to modify metadata in the same operation. + +Usage: + pda edit KEY[@STORE] [flags] + +Aliases: + edit, e + +Flags: + -d, --decrypt decrypt the value (store as plaintext) + -e, --encrypt encrypt the value at rest + --force bypass read-only protection + -h, --help help for edit + --pin pin the key (sorts to top in list) + --preserve-newline keep trailing newlines added by the editor + --readonly mark the key as read-only + --ttl string set expiry (e.g. 30m, 2h) or 'never' to clear + --unpin unpin the key + --writable clear the read-only flag +``` + +#### `pda move` + ++ + ↑ · + See also: + Moving & Copying + +
+ +```text +Move a key + +Usage: + pda move FROM[@STORE] TO[@STORE] [flags] + +Aliases: + move, mv + +Flags: + --copy copy instead of move (keeps source) + --force bypass read-only protection + -h, --help help for move + -i, --interactive prompt before overwriting destination + --safe do not overwrite if the destination already exists + -y, --yes skip all confirmation prompts +``` + +#### `pda copy` + ++ + ↑ · + See also: + Moving & Copying + +
+ +```text +Make a copy of a key + +Usage: + pda copy FROM[@STORE] TO[@STORE] [flags] + +Aliases: + copy, cp + +Flags: + --force bypass read-only protection + -h, --help help for copy + -i, --interactive prompt before overwriting destination + --safe do not overwrite if the destination already exists + -y, --yes skip all confirmation prompts +``` + +#### `pda remove` + ++ + ↑ · + See also: + Removing, + Filtering + +
+ +```text +Delete one or more keys + +Usage: + pda remove KEY[@STORE] [KEY[@STORE] ...] [flags] + +Aliases: + remove, rm + +Flags: + --force bypass read-only protection + -h, --help help for remove + -i, --interactive prompt yes/no for each deletion + -k, --key strings delete keys matching glob pattern (repeatable) + -s, --store strings target stores matching glob pattern (repeatable) + -v, --value strings delete entries matching value glob pattern (repeatable) + -y, --yes skip all confirmation prompts +``` + +#### `pda meta` + ++ + ↑ · + See also: + Metadata, + TTL, + Encryption, + Read-Only, + Pinned + +
+ +```text +View or modify metadata (TTL, encryption, read-only, pinned) for a key +without changing its value. + +With no flags, displays the key's current metadata. Pass flags to modify. + +Usage: + pda meta KEY[@STORE] [flags] + +Flags: + -d, --decrypt decrypt the value (store as plaintext) + -e, --encrypt encrypt the value at rest + --force bypass read-only protection for metadata changes + -h, --help help for meta + --pin pin the key (sorts to top in list) + --readonly mark the key as read-only + --ttl string set expiry (e.g. 30m, 2h) or 'never' to clear + --unpin unpin the key + --writable clear the read-only flag +``` + +#### `pda identity` + ++ + ↑ · + See also: + Identity, + Encryption + +
+ +```text +Show or create the age encryption identity + +Usage: + pda identity [flags] + +Aliases: + identity, id + +Flags: + --add-recipient string add an age public key as an additional encryption recipient + -h, --help help for identity + --new generate a new identity (errors if one already exists) + --path print only the identity file path + --remove-recipient string remove an age public key from the recipient list +``` + +#### `pda export` + ++ + ↑ · + See also: + Import & Export + +
+ +```text +Export store as NDJSON (alias for list --format ndjson) + +Usage: + pda export [STORE] [flags] + +Flags: + -h, --help help for export + -k, --key strings filter keys with glob pattern (repeatable) + -s, --store strings filter stores with glob pattern (repeatable) + -v, --value strings filter values with glob pattern (repeatable) +``` + +#### `pda import` + ++ + ↑ · + See also: + Import & Export + +
+ +```text +Restore key/value pairs from an NDJSON dump + +Usage: + pda import [STORE] [flags] + +Flags: + --drop drop existing entries before restoring (full replace) + -f, --file string path to an NDJSON dump (defaults to stdin) + -h, --help help for import + -i, --interactive prompt before overwriting existing keys + -k, --key strings restore keys matching glob pattern (repeatable) + -s, --store strings restore entries from stores matching glob pattern (repeatable) +``` + +#### `pda list-stores` + ++ + ↑ · + See also: + Stores + +
+ +```text +List all stores + +Usage: + pda list-stores [flags] + +Aliases: + list-stores, lss + +Flags: + -h, --help help for list-stores + --no-header suppress the header row + --short only print store names +``` + +#### `pda move-store` + ++ + ↑ · + See also: + Stores + +
+ +```text +Rename a store + +Usage: + pda move-store FROM TO [flags] + +Aliases: + move-store, mvs + +Flags: + --copy copy instead of move (keeps source) + -h, --help help for move-store + -i, --interactive prompt before overwriting destination + --safe do not overwrite if the destination store already exists + -y, --yes skip all confirmation prompts +``` + +#### `pda remove-store` + ++ + ↑ · + See also: + Stores + +
+ +```text +Delete a store + +Usage: + pda remove-store STORE [flags] + +Aliases: + remove-store, rms + +Flags: + -h, --help help for remove-store + -i, --interactive prompt yes/no for each deletion + -y, --yes skip all confirmation prompts +``` + +#### `pda init` + ++ + ↑ · + See also: + Init, + Git + +
+ +```text +Initialise pda! version control + +Usage: + pda init [remote-url] [flags] + +Flags: + --clean remove .git from stores directory before initialising + -h, --help help for init +``` + +#### `pda sync` + ++ + ↑ · + See also: + Sync, + Git + +
+ +```text +Manually sync your stores with Git + +Usage: + pda sync [flags] + +Flags: + -h, --help help for sync + -m, --message string custom commit message (defaults to timestamp) +``` + +#### `pda git` + + + +```text +Run any arbitrary command. Use with caution. + +The Git repository lives directly in the data directory +("PDA_DATA"). Store files (*.ndjson) are tracked by Git as-is. + +If you manually modify files without using the built-in +commands, you may desync your repository. + +Generally prefer "pda sync". + +Usage: + pda git [args...] [flags] + +Flags: + -h, --help help for git +``` + +#### `pda config` + ++ + ↑ · + See also: + Config + +
+ +```text +View and modify configuration + +Usage: + pda config [command] + +Available Commands: + edit Open config file in $EDITOR + get Print a configuration value + init Generate default config file + list List all configuration values + path Print config file path + set Set a configuration value + +Flags: + -h, --help help for config + +Use "pda config [command] --help" for more information about a command. +``` + +#### `pda doctor` + ++ + ↑ · + See also: + Doctor + +
+ +```text +Check environment health + +Usage: + pda doctor [flags] + +Flags: + -h, --help help for doctor +``` + +#### `pda version` + ++ + ↑ · + See also: + Version + +
+ +```text +Display pda! version + +Usage: + pda version [flags] + +Flags: + -h, --help help for version + --short print only the version string +``` + ### License