# `--save-alias` Specification
## π― Goal
Let users persist CLI invocations as reusable aliases in Keloraβs config file β quickly, safely, and without parsing or extra flags.
---
## π§Ύ Syntax
```bash
kelora [ARGS...] --save-alias <alias_name>
```
* `ARGS...` = full CLI invocation (flags, filters, inputs, etc.)
* `--save-alias <name>` = defines the alias to store
* No `--force`, no `--no-overwrite`
---
## π Behavior
1. **At runtime**:
* Detect `--save-alias <name>`
* Capture full original `argv`, excluding `--save-alias <name>`
2. **INI Update**:
* Locate user config file via standard search order (`~/.config/kelora/config.ini`, etc.)
* Update `[aliases]` section
* If the alias does **not exist**, add it
* If the alias **does exist**, overwrite it
3. **User Feedback**:
### If alias is **new**:
```
β
Alias 'errors' saved to ~/.config/kelora/config.ini
```
### If alias is **replaced**:
```
β
Alias 'errors' saved to ~/.config/kelora/config.ini
βΉοΈ Replaced previous alias:
errors = -l error --stats --brief
```
4. **Output Suggestions**:
* If successful, suggest reuse:
```
β Run with: kelora -a errors your.log
```
---
## π Config File Example
Given:
```bash
kelora -f json app.log -l error --stats --save-alias errors
```
Will write:
```ini
[aliases]
errors = -f json app.log -l error --stats
```
If `errors` existed before, its value is replaced, and the old value is shown in the terminal β **not** kept in the config.
---
## π§± Constraints
* Alias names:
* Must match regex: `^[a-zA-Z_][a-zA-Z0-9_-]{0,63}$`
* Must be unique within `[aliases]`
* Config file must be writable
* Will create `[aliases]` section if missing
---
## π Aliases in Use
Once saved:
```bash
kelora -a errors logs.json
```
expands to:
```bash
kelora -f json app.log -l error --stats logs.json
```
---
## β
Philosophy Alignment
* βοΈ CLI-native, predictable
* βοΈ No persistence beyond config
* βοΈ No silent surprises β overwrites are visible
* βοΈ Encourages composable, reusable workflows