feat: search cmd

chore: raw sql replaced with squirrel
fix: -n is now required for add cmd
This commit is contained in:
abelith committed 2026-08-15 18:38:26 +05:00
1 parent 80a90b65bb
commit 4447b7343f
9 files changed
+142 -27

No files matched your search

+47 -15
View File
@@ -1,4 +1,4 @@
# spellbook 0.2.1-alpha
# spellbook 0.3.0-alpha
`spellbook` is a lightweight CLI command manager written in Go. It allows you to save complex shell commands as parameterized templates ("spells") and execute them instantly with custom arguments.
@@ -10,6 +10,7 @@
- [Configuration](#configuration)
- [Usage](#usage)
- [Upcoming Features](#upcoming-features)
- [Known issues](#known-issues)
---
@@ -34,7 +35,7 @@ git clone https://github.com/abelith/spellbook.git
cd spellbook
# Build static binary
CGO_ENABLED=0 go build -o spellbook .
CGO_ENABLED=0 go build -ldflags="-X main.Version=0.3.0-alpha" -o spellbook .
# Move to bin directory (for Linux/macOS)
mv spellbook $(go env GOPATH)/bin/
@@ -45,7 +46,7 @@ mv spellbook $(go env GOPATH)/bin/
## Configuration
### Env
- `SPELLBOOK_DB_PATH`: db location (example: `/spellbook/spellbook.db`)
- `SPELLBOOK_DB_PATH`: database file path (example: `/spellbook/spellbook.db`)
---
@@ -58,28 +59,56 @@ mv spellbook $(go env GOPATH)/bin/
Use `spellbook` to list prepared spells
### Searching through your spellbook
Use `spellbook search -n name -c cmd -d desc -t tags [query]` to find spells matching the query
| Name | Shorthand | Description |
|----------|-----------|------------------------------------------------------------------------------|
| `--name` | `-n` | Part of a spell name to search for |
| `--cmd` | `-c` | Part of a spell command template to search for |
| `--desc` | `-d` | Part of a spell description to search for |
| `--tags` | `-t` | Comma-separated list of tags to search for |
| `query` | | General pattern to search for through spell names, descriptions and commands |
> At least one of the parameters above is required
### Add new spell
Use `spellbook add -n name -t tags -d desc -- command` to add a new spell
- `-n` or `--name` is a name of a spell
- `-t` or `--tags` is a comma-separated list of spell tags
- `-d` or `--desc` is a short description of spell
- `command` is an actual spell template
Use `spellbook add -n name -t tags -d desc -- [command]` to add a new spell
| Name | Shorthand | Description | Required |
|-----------|-----------|------------------------------------|----------|
| `--name` | `-n` | Spell name | `Yes` |
| `--tags` | `-t` | Comma-separated list of spell tags | `No` |
| `--desc` | `-d` | Spell description | `No` |
| `command` | | Spell command template | `Yes` |
> It is advised to escape the `command` with single or double quotes
### Remove a spell
Use `spellbook rm [spell_name]` to remove a spell
- `spell_name` is a name of a spell
- `spell_name` is a name of a spell `required`
| Name | Description | Required |
|--------------|-------------|----------|
| `spell_name` | Spell name | `Yes` |
### Casting a spell
Use `spellbook [spell_name] key=val` to cast a spell
- `spell_name` is a name of a spell
- `key=val` are key/value arguments
Use `spellbook [spell_name] key=val key=val` to cast a spell
| Name | Description | Required |
|--------------|------------------------------|----------|
| `spell_name` | Spell name | `Yes` |
| `key=val` | key=val formatted parameters | `No` |
### Examples
Said, you have added a spell like this
For example, if you add a spell like this
```shell
spellbook add -n my-spell -t net,http -d my-desc -- curl 127.0.0.1
@@ -106,5 +135,8 @@ spellbook my-spell target=127.0.0.1
---
## Upcoming Features
- Search to navigate your spell book
- Export/import spellbooks
- Export/import spellbooks
- Namespaces
## Known issues
- `KEY=VAL my-cmd` inline environment variable syntax is currently not supported (will fail with `executable file not found in $PATH`)