# Configuration

## The Problem

Users need to customize defaults (e.g., "I prefer Markdown over plain text"), but requiring them to find, create, and edit a hidden JSON file is poor UX.

## The Solution: Config Command + Hierarchy

Padz exposes configuration as a first-class command, backed by a simple hierarchical lookup.

### 1. Storage Hierarchy
-   **Location**: `src/padz/config.rs`
-   **Priority 1: Project Config**: `.padz/config.json`. Overrides everything for this repo.
-   **Priority 2: Global Config**: OS-appropriate config directory (via `directories` crate).
-   **Priority 3: Hardcoded Defaults**: Built-in fallbacks.

### 2. The Config Command
-   **Location**: `src/padz/cli/commands.rs` — function `handle_config`
-   **Usage**:
    -   `padz config` — Show all configuration values.
    -   `padz config <key>` — Get a specific value.
    -   `padz config <key> <value>` — Set a value (persists to the active scope's config file).

### 3. Available Settings

| Key | Default | Description |
|-----|---------|-------------|
| `file-ext` | `.txt` | Extension for new pad files (e.g., `.md`, `.txt`) |
| `import-extensions` | `.md, .txt, .text, .lex` | Extensions to look for when running `padz import .` |

### 4. Extension Behavior

**`file-ext`**:
-   Controls the extension used for *newly created* files only.
-   Changing this does **not** rename existing files.
-   Padz reads files with any extension that matches the `pad-{UUID}.*` pattern.
-   When reading, it tries the configured extension first, then falls back to `.txt`.

**`import-extensions`**:
-   Comma-separated list of extensions.
-   Used by `padz import <directory>` to filter which files to import.
-   Example: `padz config import-extensions ".md, .txt"`

### Developer Note

The `PadzConfig` struct uses `serde` with `#[serde(default)]` for all fields. This ensures that older config files missing new fields will use defaults without errors.
